docs: def validate_lv_districts(session, nw):
      '''Validate if total load of a grid in a pkl file is what expected from LV districts
  
      Parameters
      ----------
      session : sqlalchemy.orm.session.Session
              Database session
      nw: 
          The network
  
      Returns
      -------
      DataFrame
          compare_by_district
      DataFrame
          compare_by_loads
      '''
      # config network intern variables
      nw._config = nw.import_config()
      nw._pf_config = nw.import_pf_config()
      nw._static_data = nw.import_static_data()
      nw._orm = nw.import_orm()
  
      # rescue peak load from input table
      lv_ditricts = [dist.id_db for mv in nw.mv_grid_districts()
                                for la in mv.lv_load_areas()
                                for dist in la.lv_grid_districts()]
      load_input = nw.list_lv_grid_districts(session, lv_ditricts)
      load_input = load_input.sum(axis=0).apply(lambda x: np.round(x, 3))
      load_input.sort_index(inplace=True)
      load_input.index.names = ['id_db']
      load_input['peak_load_retind']=load_input['peak_load_retail']+load_input['peak_load_industrial']
  
      # search for lv_district in the grid
      lv_dist_idx = 0
      lv_dist_dict = {}
      lv_load_idx = 0
      lv_load_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
                  lv_dist_dict[lv_dist_idx] = {
                      'id_db':lv_district.id_db,
                      '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,
                      'peak_load_retind': lv_district.peak_load_industrial + lv_district.peak_load_retail,
                  }
                  for node in lv_district.lv_grid.graph_nodes_sorted():
                      if isinstance(node,LVLoadDing0):
                          lv_load_idx +=1
                          peak_load_agricultural = 0
                          peak_load_residential = 0
                          peak_load_retail = 0
                          peak_load_industrial = 0
                          peak_load_retind = 0
  
                          if 'agricultural' in node.consumption:
                              tipo = 'agricultural'
                              peak_load_agricultural = node.peak_load
                          elif 'industrial' in node.consumption:
                              if node.consumption['retail']==0:
                                  tipo = 'industrial'
                                  peak_load_industrial = node.peak_load
                              elif node.consumption['industrial']==0:
                                  tipo = 'retail'
                                  peak_load_retail = node.peak_load
                              else:
                                  tipo = 'ret_ind'
                                  peak_load_retind = node.peak_load
                          elif 'residential' in node.consumption:
                              tipo = 'residential'
                              peak_load_residential = node.peak_load
                          else:
                              tipo = 'none'
                              print(node.consumption)
                          lv_load_dict[lv_load_idx] = {
                              'id_db':node.id_db,
                              'peak_load_residential':peak_load_residential,
                              'peak_load_retail':peak_load_retail,
                              'peak_load_industrial':peak_load_industrial,
                              'peak_load_agricultural':peak_load_agricultural,
                              'peak_load_retind':peak_load_retind,
                          }
  
          for node in mv_district.mv_grid.graph_nodes_sorted():
              if isinstance(node,LVLoadAreaCentreDing0):
                  lv_load_idx +=1
                  lv_load_dict[lv_load_idx] = {
                      'id_db': node.id_db,
                      'peak_load_residential': node.lv_load_area.peak_load_residential,
                      'peak_load_retail': node.lv_load_area.peak_load_retail,
                      'peak_load_industrial': node.lv_load_area.peak_load_industrial,
                      'peak_load_agricultural': node.lv_load_area.peak_load_agricultural,
                      'peak_load_retind':0,
                  }
  
      #compare by LV district
      load_effective_lv_distr = pd.DataFrame.from_dict(lv_dist_dict,orient='index').set_index('id_db').sum(axis=0).apply(lambda x: np.round(x,3))
      load_effective_lv_distr.sort_index(inplace=True)
  
      compare_by_district = pd.concat([load_input,load_effective_lv_distr,load_input==load_effective_lv_distr],axis=1)
      compare_by_district.columns = ['table','ding0','equal?']
      compare_by_district.index.names = ['sector']
  
      #compare by LV Loads
      load_effective_lv_load = pd.DataFrame.from_dict(lv_load_dict,orient='index').set_index('id_db')
      load_effective_lv_load = load_effective_lv_load.sum(axis=0).apply(lambda x: np.round(x,3))
      load_effective_lv_load.sort_index(inplace=True)
  
      load_effective_lv_load['peak_load_retind'] = load_effective_lv_load['peak_load_retail'] + \
                                                   load_effective_lv_load['peak_load_industrial'] + \
                                                   load_effective_lv_load['peak_load_retind']
  
      compare_by_load = pd.concat([load_input,load_effective_lv_load,load_input==load_effective_lv_load],axis=1)
      compare_by_load.columns = ['table','ding0','equal?']
      compare_by_load.index.names = ['sector']
  
      return compare_by_district, compare_by_load