'merge' 2 dataframes on elements from list?

前端 未结 4 1251
刺人心
刺人心 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 07:07

    Here is one way

    df9['text']=df9['text'].str[0]
    
    l=[df9.loc[x,'text'].tolist() for x in df8.names]
    Out[505]: [['hi im hans', 'hi im meier'], ['hi im debby', 'hi im harry', 'hi im peter']]
    
    df9['cont']=l
    

提交回复
热议问题