I'm confused on how do I add a column to another in pandas
Here is what I'm trying to do :
from pandas import DataFrame
df1 = DataFrame({'a':[1,2], 'b':[3,4]})
concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
Which do return what I want : A serie with my 4 values. What I don't understand is : Why I can't assign it to column 'a' ?
>>> from pandas import DataFrame
>>> df1 = DataFrame({'a':[1,2], 'b':[3,4]})
>>> concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
0 1
1 2
2 3
3 4
dtype: int64
>>> df1['a'] = concat((df1['a'], df1['b'].rename({'b':'a'}))).reset_index(drop=True)
>>> df1
a b
0 1 3
1 2 4
Is there any way to make it more readable by the way? I'm confused on how it should worked... Note that I don't need column 'b' afterward.
Thanks for your help :)
Sam