docs: def calculate_lvgd_stats(nw):
      """
      LV Statistics for an arbitrary network
  
      Parameters
      ----------
      nw: :any:`list` of NetworkDing0
          The MV grid(s) to be studied
  
      Returns
      -------
      lvgd_stats : pandas.DataFrame
          Dataframe containing several statistical numbers about the LVGD
      """
      ##############################
      #  ETRS (equidistant) to WGS84 (conformal) projection
      proj = partial(
          pyproj.transform,
          # pyproj.Proj(init='epsg:3035'),  # source coordinate system
          #  pyproj.Proj(init='epsg:4326'))  # destination coordinate system
          pyproj.Proj(init='epsg:4326'),  # source coordinate system
          pyproj.Proj(init='epsg:3035'))  # destination coordinate system
      ##############################
      # close circuit breakers
      nw.control_circuit_breakers(mode='close')
      ##############################
      lv_dist_idx = 0
      lv_dist_dict = {}
      lv_gen_idx = 0
      lv_gen_dict = {}
      lv_load_idx = 0
      lv_load_dict = {}
      branch_idx = 0
      branches_dict = {}
      trafos_idx = 0
      trafos_dict = {}
      for mv_district in nw.mv_grid_districts():
          for LA in mv_district.lv_load_areas():
              for lv_district in LA.lv_grid_districts():
                  lv_dist_idx += 1
                  branches_from_station = len(lv_district.lv_grid.graph_branches_from_node(lv_district.lv_grid.station()))
                  lv_dist_dict[lv_dist_idx] = {
                      'MV_grid_id': mv_district.mv_grid.id_db,
                      'LV_grid_id': lv_district.lv_grid.id_db,
                      'Load Area ID': LA.id_db,
                      'Population': lv_district.population,
                      'Peak Load Residential': lv_district.peak_load_residential,
                      'Peak Load Retail': lv_district.peak_load_retail,
                      'Peak Load Industrial': lv_district.peak_load_industrial,
                      'Peak Load Agricultural': lv_district.peak_load_agricultural,
                      'N° of Sector Residential': lv_district.sector_count_residential,
                      'N° of Sector Retail': lv_district.sector_count_retail,
                      'N° of Sector Industrial': lv_district.sector_count_industrial,
                      'N° of Sector Agricultural': lv_district.sector_count_agricultural,
                      'Accum. Consumption Residential': lv_district.sector_consumption_residential,
                      'Accum. Consumption Retail': lv_district.sector_consumption_retail,
                      'Accum. Consumption Industrial': lv_district.sector_consumption_industrial,
                      'Accum. Consumption Agricultural': lv_district.sector_consumption_agricultural,
                      'N° of branches from LV Station': branches_from_station,
                      'Load Area is Aggregated': LA.is_aggregated,
                      'Load Area is Satellite': LA.is_satellite,
                  }
                  # generation capacity
                  for g in lv_district.lv_grid.generators():
                      lv_gen_idx += 1
                      subtype = g.subtype
                      if subtype == None:
                          subtype = 'other'
                      type = g.type
                      if type == None:
                          type = 'other'
                      lv_gen_dict[lv_gen_idx] = {
                          'LV_grid_id': lv_district.lv_grid.id_db,
                          'v_level': g.v_level,
                          'subtype': type + '/' + subtype,
                          'GenCap': g.capacity,
                      }
                  # nodes bzw. LV loads
                  for node in lv_district.lv_grid.graph_nodes_sorted():
                      if isinstance(node, LVLoadDing0):
                          lv_load_idx += 1
                          if 'agricultural' in node.consumption:
                              tipo = 'agricultural'
                          elif 'industrial' in node.consumption:
                              tipo = 'ind_ret'
                          elif 'residential' in node.consumption:
                              tipo = 'residential'
                          else:
                              tipo = 'none'
                          lv_load_dict[lv_load_idx] = {
                              'LV_grid_id': lv_district.lv_grid.id_db,
                              'load_type': tipo,
                          }
                  # branches
                  for branch in lv_district.lv_grid.graph_edges():
                      branch_idx += 1
                      branches_dict[branch_idx] = {
                          'LV_grid_id': lv_district.lv_grid.id_db,
                          'length': branch['branch'].length / 1e3,
                          'type_name': branch['branch'].type.to_frame().columns[0],
                          'type_kind': branch['branch'].kind,
                      }
                  # Transformers
                  for trafo in lv_district.lv_grid.station().transformers():
                      trafos_idx += 1
                      trafos_dict[trafos_idx] = {
                          'LV_grid_id': lv_district.lv_grid.id_db,
                          's_max_a': trafo.s_max_a,
                      }
  
                  # geographic
                  district_geo = transform(proj, lv_district.geo_data)
                  lv_dist_dict[lv_dist_idx].update({'Area': district_geo.area})
  
      lvgd_stats = pd.DataFrame.from_dict(lv_dist_dict, orient='index').set_index('LV_grid_id')
      # generate partial dataframes
      gen_df = pd.DataFrame.from_dict(lv_gen_dict, orient='index')
      load_df = pd.DataFrame.from_dict(lv_load_dict, orient='index')
      branch_df = pd.DataFrame.from_dict(branches_dict, orient='index')
      trafos_df = pd.DataFrame.from_dict(trafos_dict, orient='index')
  
      # resque desired data
      if not gen_df.empty:
          # generation by voltage level
          lv_generation = gen_df.groupby(['LV_grid_id', 'v_level'])['GenCap'].sum().to_frame().unstack(level=-1)
          lv_generation.columns = ['Gen. Cap. v_level ' + str(_[1]) if isinstance(_, tuple) else str(_) for _ in
                                   lv_generation.columns]
          lvgd_stats = pd.concat([lvgd_stats, lv_generation], axis=1)
          # generation by type/subtype
          lv_generation = gen_df.groupby(['LV_grid_id', 'subtype'])['GenCap'].sum().to_frame().unstack(level=-1)
          lv_generation.columns = ['Gen. Cap. type ' + str(_[1]) if isinstance(_, tuple) else str(_) for _ in
                                   lv_generation.columns]
          lvgd_stats = pd.concat([lvgd_stats, lv_generation], axis=1)
      if not load_df.empty:
          # number of residential loads
          lv_loads = load_df[load_df['load_type'] == 'residential'].groupby(['LV_grid_id'])[
              'load_type'].count().to_frame()  # .unstack(level=-1)
          lv_loads.columns = ['N° of loads residential']
          lvgd_stats = pd.concat([lvgd_stats, lv_loads], axis=1)
          # number of agricultural loads
          lv_loads = load_df[load_df['load_type'] == 'agricultural'].groupby(['LV_grid_id'])[
              'load_type'].count().to_frame()  # .unstack(level=-1)
          lv_loads.columns = ['N° of loads agricultural']
          lvgd_stats = pd.concat([lvgd_stats, lv_loads], axis=1)
          # number of mixed industrial / retail loads
          lv_loads = load_df[load_df['load_type'] == 'ind_ret'].groupby(['LV_grid_id'])[
              'load_type'].count().to_frame()  # .unstack(level=-1)
          lv_loads.columns = ['N° of loads mixed industrial/retail']
          lvgd_stats = pd.concat([lvgd_stats, lv_loads], axis=1)
  
      if not branch_df.empty:
          # branches by type name
          lv_branches = branch_df.groupby(['LV_grid_id', 'type_name'])['length'].sum().to_frame().unstack(level=-1)
          lv_branches.columns = ['Length Type ' + _[1] if isinstance(_, tuple) else _ for _ in lv_branches.columns]
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
          # branches by kind
          lv_branches = branch_df[branch_df['type_kind'] == 'line'].groupby(['LV_grid_id'])['length'].sum().to_frame()
          lv_branches.columns = ['Length of overhead lines']
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
          lv_branches = branch_df[branch_df['type_kind'] == 'cable'].groupby(['LV_grid_id'])['length'].sum().to_frame()
          lv_branches.columns = ['Length of underground cables']
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
          # N°of branches
          lv_branches = branch_df.groupby(['LV_grid_id', 'type_name'])['length'].count().to_frame().unstack(level=-1)
          lv_branches.columns = ['N° of branches Type ' + _[1] if isinstance(_, tuple) else _ for _ in
                                 lv_branches.columns]
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
          lv_branches = branch_df[branch_df['type_kind'] == 'line'].groupby(['LV_grid_id'])['length'].count().to_frame()
          lv_branches.columns = ['N° of branches overhead lines']
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
          lv_branches = branch_df[branch_df['type_kind'] == 'cable'].groupby(['LV_grid_id'])['length'].count().to_frame()
          lv_branches.columns = ['N° of branches underground cables']
          lvgd_stats = pd.concat([lvgd_stats, lv_branches], axis=1)
      if not trafos_df.empty:
          # N of trafos
          lv_trafos = trafos_df.groupby(['LV_grid_id'])['s_max_a'].count().to_frame()
          lv_trafos.columns = ['N° of MV/LV Trafos']
          lvgd_stats = pd.concat([lvgd_stats, lv_trafos], axis=1)
          # Capacity of trafos
          lv_trafos = trafos_df.groupby(['LV_grid_id'])['s_max_a'].sum().to_frame()
          lv_trafos.columns = ['Accumulated s_max_a in MVLV trafos']
          lvgd_stats = pd.concat([lvgd_stats, lv_trafos], axis=1)
  
      lvgd_stats = lvgd_stats.fillna(0)
      lvgd_stats = lvgd_stats[sorted(lvgd_stats.columns.tolist())]
      return lvgd_stats