0

I have two dataframes, df_source, and df_dest as follows:

>>> df_source = pd.read_csv('Product_Lookup.csv')
>>> df_source
   ProdCode    ProdName        ProdUPC  ProdQty
0       131       Apple  1100034030045        1
1       320   Bookshelf  2222200209090        1
2       420  Comic Book  4449435895489        5
3       511   Drillbits  5558493958393       10
4        55        Eggs  6660001110005       20
5        12   Fish food  9099910002776       50

>>> df_dest = pd.read_csv('Product_Dest.csv')
>>> df_dest
  CustName  ProdCode  ProdName  ProdUPC  ProdQty
0     Fred        12       nan      nan      nan
1   Sanjay       131       nan      nan      nan
2     Rita       55        nan      nan      nan
3    Steph       511       nan      nan      nan
4   Hannah        55       nan      nan      nan
5    Roger       131       nan      nan      nan

I've not seen a question here yet for pandas that handles multi-column population in a lookup function.

I am trying to populate df_dest.loc[:,['ProdName','ProdUPC','ProdQty']] by matching df_dest['ProdCode'] with df_source['ProdCode'].

I could do it with iterrows(), but hoping for something faster and a little more elegant. Any help super appreciated!

rabbitholefinder
  • 129
  • 2
  • 13

0 Answers0