Python - function similar to VLOOKUP (Excel)

后端 未结 4 1827
鱼传尺愫
鱼传尺愫 2021-02-05 23:00

i am trying to join two data frames but cannot get my head around the possibilities Python has to offer.

First dataframe:

ID MODEL   REQUESTS ORDERS
1  G         


        
4条回答
  •  春和景丽
    2021-02-05 23:23

    I always found merge to be an easy way to do this:

    df1.merge(df2[['MODEL', 'MAKE']], how = 'left')
    

    However, I must admit it would not be as short and nice if you wanted to call the new column something else than 'MAKE'.

提交回复
热议问题