I want to do the following merge (hard to describe in words): This are my Dataframes
df8=pd.DataFrame({'names':[['Hans','Meier'],['Debby','Harry','Peter']]})
names
0 ['Hans','Meier']
1 ['Debby','Harry','Peter']
df9=pd.DataFrame({'caller':['Hans','Meier','Debby','Harry','Peter'],'text':[['hi im hans'],['hi im meier'],['hi im debby'],['hi im harry'],['hi im peter']]})
df9.set_index(df9.caller, inplace = True)
df9.drop('caller', axis = 1, inplace = True)
caller text
Hans ['hi im hans']
Meier ['hi im meier']
.
.
.
The result should look like this
names content
0 ['Hans','Meier'] ['hi im hans', 'hi im meier']
1 ['Debby','Harry','Peter'] ['hi im debby', 'hi im harry', 'hi im peter']
So that the texts said by the persons in df9 will appear in df8 if the person is an element of the respective names list.
i think it is a similar question to this but i dont see a solution there
i looked into the pandas documentation about concatenate, join and merge but didnt find there a solution either