code: def reindex(series1, series2):
      
  
      # turns out the merge is much faster than the .loc below
      df = pd.merge(pd.DataFrame({"left": series2}),
                    pd.DataFrame({"right": series1}),
                    left_on="left",
                    right_index=True,
                    how="left")
      return df.right
docs: This reindexes the first series by the second series.  This is an extremely
      common operation that does not appear to  be in Pandas at this time.
      If anyone knows of an easier way to do this in Pandas, please inform the
      UrbanSim developers.
  
      The canonical example would be a parcel series which has an index which is
      parcel_ids and a value which you want to fetch, let's say it's land_area.
      Another dataset, let's say of buildings has a series which indicate the
      parcel_ids that the buildings are located on, but which does not have
      land_area.  If you pass parcels.land_area as the first series and
      buildings.parcel_id as the second series, this function returns a series
      which is indexed by buildings and has land_area as values and can be
      added to the buildings dataset.
  
      In short, this is a join on to a different table using a foreign key
      stored in the current table, but with only one attribute rather than
      for a full dataset.
  
      This is very similar to the pandas "loc" function or "reindex" function,
      but neither of those functions return the series indexed on the current
      table.  In both of those cases, the series would be indexed on the foreign
      table and would require a second step to change the index.