docs: def nodes_to_dict_of_dataframes(grid, nodes, lv_transformer=True):
      """
      Creates dictionary of dataframes containing grid
  
      Parameters
      ----------
      grid: ding0.Network
      nodes: list of ding0 grid components objects
          Nodes of the grid graph
      lv_transformer: bool, True
          Toggle transformer representation in power flow analysis
  
      Returns:
      components: dict of pandas.DataFrame
          DataFrames contain components attributes. Dict is keyed by components
          type
      components_data: dict of pandas.DataFrame
          DataFrame containing components time-varying data
      """
  
      generator_instances = [MVStationDing0, GeneratorDing0]
      # TODO: MVStationDing0 has a slack generator
  
      cos_phi_load = cfg_ding0.get('assumptions', 'cos_phi_load')
      cos_phi_feedin = cfg_ding0.get('assumptions', 'cos_phi_gen')
      srid = int(cfg_ding0.get('geo', 'srid'))
  
      load_in_generation_case = cfg_ding0.get('assumptions',
                                              'load_in_generation_case')
      generation_in_load_case = cfg_ding0.get('assumptions',
                                              'generation_in_load_case')
  
      Q_factor_load = tan(acos(cos_phi_load))
      Q_factor_generation = tan(acos(cos_phi_feedin))
  
      voltage_set_slack = cfg_ding0.get("mv_routing_tech_constraints",
                                        "mv_station_v_level_operation")
  
      kw2mw = 1e-3
  
      # define dictionaries
      buses = {'bus_id': [], 'v_nom': [], 'geom': [], 'grid_id': []}
      bus_v_mag_set = {'bus_id': [], 'temp_id': [], 'v_mag_pu_set': [],
                       'grid_id': []}
      generator = {'generator_id': [], 'bus': [], 'control': [], 'grid_id': [],
                   'p_nom': []}
      generator_pq_set = {'generator_id': [], 'temp_id': [], 'p_set': [],
                          'grid_id': [], 'q_set': []}
      load = {'load_id': [], 'bus': [], 'grid_id': []}
      load_pq_set = {'load_id': [], 'temp_id': [], 'p_set': [],
                     'grid_id': [], 'q_set': []}
  
      # # TODO: consider other implications of `lv_transformer is True`
      # if lv_transformer is True:
      #     bus_instances.append(Transformer)
  
      # # TODO: only for debugging, remove afterwards
      # import csv
      # nodeslist = sorted([node.__repr__() for node in nodes
      #                     if node not in grid.graph_isolated_nodes()])
      # with open('/home/guido/ding0_debug/nodes_via_dataframe.csv', 'w', newline='') as csvfile:
      #     writer = csv.writer(csvfile, delimiter='\n')
      #     writer.writerow(nodeslist)
  
      for node in nodes:
          if node not in grid.graph_isolated_nodes():
              # buses only
              if isinstance(node, MVCableDistributorDing0):
                  buses['bus_id'].append(node.pypsa_id)
                  buses['v_nom'].append(grid.v_level)
                  buses['geom'].append(from_shape(node.geo_data, srid=srid))
                  buses['grid_id'].append(grid.id_db)
  
                  bus_v_mag_set['bus_id'].append(node.pypsa_id)
                  bus_v_mag_set['temp_id'].append(1)
                  bus_v_mag_set['v_mag_pu_set'].append([1, 1])
                  bus_v_mag_set['grid_id'].append(grid.id_db)
  
              # bus + generator
              elif isinstance(node, tuple(generator_instances)):
                  # slack generator
                  if isinstance(node, MVStationDing0):
                      logger.info('Only MV side bus of MVStation will be added.')
                      generator['generator_id'].append(
                          '_'.join(['MV', str(grid.id_db), 'slack']))
                      generator['control'].append('Slack')
                      generator['p_nom'].append(0)
                      bus_v_mag_set['v_mag_pu_set'].append(
                          [voltage_set_slack, voltage_set_slack])
  
                  # other generators
                  if isinstance(node, GeneratorDing0):
                      generator['generator_id'].append('_'.join(
                          ['MV', str(grid.id_db), 'gen', str(node.id_db)]))
                      generator['control'].append('PQ')
                      generator['p_nom'].append(node.capacity * node.capacity_factor)
  
                      generator_pq_set['generator_id'].append('_'.join(
                          ['MV', str(grid.id_db), 'gen', str(node.id_db)]))
                      generator_pq_set['temp_id'].append(1)
                      generator_pq_set['p_set'].append(
                          [node.capacity * node.capacity_factor * kw2mw * generation_in_load_case,
                           node.capacity * node.capacity_factor * kw2mw])
                      generator_pq_set['q_set'].append(
                          [node.capacity * node.capacity_factor * kw2mw * Q_factor_generation * generation_in_load_case,
                           node.capacity * node.capacity_factor * kw2mw * Q_factor_generation])
                      generator_pq_set['grid_id'].append(grid.id_db)
                      bus_v_mag_set['v_mag_pu_set'].append([1, 1])
  
                  buses['bus_id'].append(node.pypsa_id)
                  buses['v_nom'].append(grid.v_level)
                  buses['geom'].append(from_shape(node.geo_data, srid=srid))
                  buses['grid_id'].append(grid.id_db)
  
                  bus_v_mag_set['bus_id'].append(node.pypsa_id)
                  bus_v_mag_set['temp_id'].append(1)
                  bus_v_mag_set['grid_id'].append(grid.id_db)
  
                  generator['grid_id'].append(grid.id_db)
                  generator['bus'].append(node.pypsa_id)
  
  
              # aggregated load at hv/mv substation
              elif isinstance(node, LVLoadAreaCentreDing0):
                  load['load_id'].append(node.pypsa_id)
                  load['bus'].append('_'.join(['HV', str(grid.id_db), 'trd']))
                  load['grid_id'].append(grid.id_db)
  
                  load_pq_set['load_id'].append(node.pypsa_id)
                  load_pq_set['temp_id'].append(1)
                  load_pq_set['p_set'].append(
                      [node.lv_load_area.peak_load * kw2mw,
                       node.lv_load_area.peak_load * kw2mw * load_in_generation_case])
                  load_pq_set['q_set'].append(
                      [node.lv_load_area.peak_load * kw2mw * Q_factor_load,
                       node.lv_load_area.peak_load * kw2mw * Q_factor_load * load_in_generation_case])
                  load_pq_set['grid_id'].append(grid.id_db)
  
                  # generator representing generation capacity of aggregate LA
                  # analogously to load, generation is connected directly to
                  # HV-MV substation
                  generator['generator_id'].append('_'.join(
                      ['MV', str(grid.id_db), 'lcg', str(node.id_db)]))
                  generator['control'].append('PQ')
                  generator['p_nom'].append(node.lv_load_area.peak_generation)
                  generator['grid_id'].append(grid.id_db)
                  generator['bus'].append('_'.join(['HV', str(grid.id_db), 'trd']))
  
                  generator_pq_set['generator_id'].append('_'.join(
                      ['MV', str(grid.id_db), 'lcg', str(node.id_db)]))
                  generator_pq_set['temp_id'].append(1)
                  generator_pq_set['p_set'].append(
                      [node.lv_load_area.peak_generation * kw2mw * generation_in_load_case,
                       node.lv_load_area.peak_generation * kw2mw])
                  generator_pq_set['q_set'].append(
                      [node.lv_load_area.peak_generation * kw2mw * Q_factor_generation * generation_in_load_case,
                       node.lv_load_area.peak_generation * kw2mw * Q_factor_generation])
                  generator_pq_set['grid_id'].append(grid.id_db)
  
              # bus + aggregate load of lv grids (at mv/ls substation)
              elif isinstance(node, LVStationDing0):
                  # Aggregated load representing load in LV grid
                  load['load_id'].append(
                      '_'.join(['MV', str(grid.id_db), 'loa', str(node.id_db)]))
                  load['bus'].append(node.pypsa_id)
                  load['grid_id'].append(grid.id_db)
  
                  load_pq_set['load_id'].append(
                      '_'.join(['MV', str(grid.id_db), 'loa', str(node.id_db)]))
                  load_pq_set['temp_id'].append(1)
                  load_pq_set['p_set'].append(
                      [node.peak_load * kw2mw,
                       node.peak_load * kw2mw * load_in_generation_case])
                  load_pq_set['q_set'].append(
                      [node.peak_load * kw2mw * Q_factor_load,
                       node.peak_load * kw2mw * Q_factor_load * load_in_generation_case])
                  load_pq_set['grid_id'].append(grid.id_db)
  
                  # bus at primary MV-LV transformer side
                  buses['bus_id'].append(node.pypsa_id)
                  buses['v_nom'].append(grid.v_level)
                  buses['geom'].append(from_shape(node.geo_data, srid=srid))
                  buses['grid_id'].append(grid.id_db)
  
                  bus_v_mag_set['bus_id'].append(node.pypsa_id)
                  bus_v_mag_set['temp_id'].append(1)
                  bus_v_mag_set['v_mag_pu_set'].append([1, 1])
                  bus_v_mag_set['grid_id'].append(grid.id_db)
  
                  # generator representing generation capacity in LV grid
                  generator['generator_id'].append('_'.join(
                      ['MV', str(grid.id_db), 'gen', str(node.id_db)]))
                  generator['control'].append('PQ')
                  generator['p_nom'].append(node.peak_generation)
                  generator['grid_id'].append(grid.id_db)
                  generator['bus'].append(node.pypsa_id)
  
                  generator_pq_set['generator_id'].append('_'.join(
                      ['MV', str(grid.id_db), 'gen', str(node.id_db)]))
                  generator_pq_set['temp_id'].append(1)
                  generator_pq_set['p_set'].append(
                      [node.peak_generation * kw2mw * generation_in_load_case,
                       node.peak_generation * kw2mw])
                  generator_pq_set['q_set'].append(
                      [node.peak_generation * kw2mw * Q_factor_generation * generation_in_load_case,
                       node.peak_generation * kw2mw * Q_factor_generation])
                  generator_pq_set['grid_id'].append(grid.id_db)
  
              elif isinstance(node, CircuitBreakerDing0):
                  # TODO: remove this elif-case if CircuitBreaker are removed from graph
                  continue
              else:
                  raise TypeError("Node of type", node, "cannot be handled here")
          else:
              if not isinstance(node, CircuitBreakerDing0):
                  add_info =  "LA is aggr. {0}".format(
                      node.lv_load_area.is_aggregated)
              else:
                  add_info = ""
              logger.warning("Node {0} is not connected to the graph and will " \
                    "be omitted in power flow analysis. {1}".format(
                  node, add_info))
  
      components = {'Bus': DataFrame(buses).set_index('bus_id'),
                    'Generator': DataFrame(generator).set_index('generator_id'),
                    'Load': DataFrame(load).set_index('load_id')}
  
      components_data = {'Bus': DataFrame(bus_v_mag_set).set_index('bus_id'),
                         'Generator': DataFrame(generator_pq_set).set_index(
                             'generator_id'),
                         'Load': DataFrame(load_pq_set).set_index('load_id')}
  
      # with open('/home/guido/ding0_debug/number_of_nodes_buses.csv', 'a') as csvfile:
      #     csvfile.write(','.join(['\n', str(len(nodes)), str(len(grid.graph_isolated_nodes())), str(len(components['Bus']))]))
  
      return components, components_data