I have the following df
d = {'col1': [1, 2], 'col2': [3, 4], 'col3':["dog", "cat"]}
df = pd.DataFrame(data=d)
col1 col2 col3
0 1 3 dog
1 2 4 cat
If I wanted to change the value in col3 in rows which col1=1 and col2=3 to fox I would do:
df.loc[(df.col1==1)&(df.col2==3), "col3"]="fox"
col1 col2 col3
0 1 3 fox
1 2 4 cat
Instead of changing dog to fox I want to append it, like so:
col1 col2 col3
0 1 3 dog, fox
1 2 4 cat
How can I do this?
Just join them using
+