For a pandas dataframe:
Name: Tags:
'One' ['tag1', 'tag3']
'Two' []
'Three' ['tag1']
How can 'tag2' be appended to the tags lists?
I have tried the following (addtag2 is another df):
df['Tags'] = df['Tags'].astype(str) + ', ' + addtag2['Tags'].astype(str)
and
df['Tags'] = df['Tags'].add(addtag2['Tags'].astype(str))
But they append the string outside the list eg ['tag1'], tag2 or ['tag1']tag2
The desired output would be:
Name: Tags:
'One' ['tag1', 'tag3', 'tag2']
'Two' ['tag2']
'Three' ['tag1', 'tag2']