replace column values in one dataframe by values of another dataframe

前端 未结 5 1335
梦如初夏
梦如初夏 2020-11-27 16:49

I have two dataframes , the first one has 1000 rows and looks like:

Date            Group         Family       Bonus
2011-06-09      tri23_1       Laavin             


        
5条回答
  •  情歌与酒
    2020-11-27 17:29

    You could also create a dictionary and use apply:

    hotel_dict = df2.set_index('Group').to_dict()
    df1['Group'] = df1['Group'].apply(lambda x: hotel_dict[x])
    

提交回复
热议问题