original_docstring: Adds longitude and latitude information to bus, plant and branch data
          frames of grid instance.
  
      :param powersimdata.input.grid.Grid grid: grid instance.
      
docstring: Adds longitude and latitude information to bus, plant and branch data
  frames of grid instance.
docstring_tokens: Adds longitude and latitude information to bus plant and branch data frames of grid instance .
code: def add_coord_to_grid_data_frames(grid):
      """Adds longitude and latitude information to bus, plant and branch data
          frames of grid instance.
  
      :param powersimdata.input.grid.Grid grid: grid instance.
      """
      bus2coord = (
          pd.merge(grid.bus2sub[["sub_id"]], grid.sub[["lat", "lon"]], on="sub_id")
          .set_index(grid.bus2sub.index)
          .drop(columns="sub_id")
          .to_dict()
      )
  
      def get_lat(idx):
          return [bus2coord["lat"][i] for i in idx]
  
      def get_lon(idx):
          return [bus2coord["lon"][i] for i in idx]
  
      extra_col_bus = {"lat": get_lat(grid.bus.index), "lon": get_lon(grid.bus.index)}
      add_column_to_data_frame(grid.bus, extra_col_bus)
  
      extra_col_plant = {
          "lat": get_lat(grid.plant.bus_id),
          "lon": get_lon(grid.plant.bus_id),
      }
      add_column_to_data_frame(grid.plant, extra_col_plant)
  
      extra_col_branch = {
          "from_lat": get_lat(grid.branch.from_bus_id),
          "from_lon": get_lon(grid.branch.from_bus_id),
          "to_lat": get_lat(grid.branch.to_bus_id),
          "to_lon": get_lon(grid.branch.to_bus_id),
      }
      add_column_to_data_frame(grid.branch, extra_col_branch)
code_tokens: def add_coord_to_grid_data_frames ( grid ) : bus2coord = ( pd . merge ( grid . bus2sub [ [ "sub_id" ] ] , grid . sub [ [ "lat" , "lon" ] ] , on = "sub_id" ) . set_index ( grid . bus2sub . index ) . drop ( columns = "sub_id" ) . to_dict ( ) ) def get_lat ( idx ) : return [ bus2coord [ "lat" ] [ i ] for i in idx ] def get_lon ( idx ) : return [ bus2coord [ "lon" ] [ i ] for i in idx ] extra_col_bus = { "lat" : get_lat ( grid . bus . index ) , "lon" : get_lon ( grid . bus . index ) } add_column_to_data_frame ( grid . bus , extra_col_bus ) extra_col_plant = { "lat" : get_lat ( grid . plant . bus_id ) , "lon" : get_lon ( grid . plant . bus_id ) , } add_column_to_data_frame ( grid . plant , extra_col_plant ) extra_col_branch = { "from_lat" : get_lat ( grid . branch . from_bus_id ) , "from_lon" : get_lon ( grid . branch . from_bus_id ) , "to_lat" : get_lat ( grid . branch . to_bus_id ) , "to_lon" : get_lon ( grid . branch . to_bus_id ) , } add_column_to_data_frame ( grid . branch , extra_col_branch )
short_docstring: Adds longitude and latitude information to bus, plant and branch data
  frames of grid instance.
short_docstring_tokens: Adds longitude and latitude information to bus plant and branch data frames of grid instance .
comment: """Adds longitude and latitude information to bus, plant and branch data
          frames of grid instance.
  
      :param powersimdata.input.grid.Grid grid: grid instance.
      """