I have two dataframes with two columns each:
df1:
C1 C2
0 x a
1 y b
2 z c
df2:
C1 C2
0 q s
1 r u
2 t v
I want to make a third column that concatenates both columns. I want to make a third dataframe such that:
d3:
C1 C2
0 q as
1 r bu
2 t cv
To do this I have used: d3['C2'] = d1['C2'] + d2['C2']. This seems to work with one of my columns, as well as with some dummy data I've created. However, for some other columns (which has the exact same data), it doesn't seem to work. Instead I d2['C2'] seems to overwrite d3['C2'] and all I see is d2['C2'] data in that column.
I tried something like:
df.apply(lambda x:'%s is %s' % (x['bar'],x['foo']),axis=1)
However, not only did it take extremely long (I have hundreds of thousands of rows in my data) but it didn't seem to work.
What am I doing wrong? Why would that method work for one column, but not the other?