'merge' 2 dataframes on elements from list?

前端 未结 4 1253
刺人心
刺人心 2021-01-23 06:20

I want to do the following merge (hard to describe in words): This are my Dataframes

df8=pd.DataFrame({\'names\':[[\'Hans\',\'Meier\'],[\'Debby\',\'Harry\',\'Pet         


        
4条回答
  •  粉色の甜心
    2021-01-23 06:59

    You can lookup the values in df9:

    df8['contents'] = df8['names'].apply(lambda l: [df9['text'].loc[name] for name in l])
    

提交回复
热议问题