I need to create a new data frame from columns of two other data frames
df1 = A,
B,
C
df2 = X,
Y,
Z
the indexes are same, when i use the code what happens is this
#df3 = pd.concat(df['A'], df['B'], axis=1, keys=['A', 'B'])
df3 = A,
B,
C,
Nan, X
Nan, Y
Nan, Z
I need the X,Y,Z next to A,B,C
Concat and DataFrame
Edit 1: 2nd DF is a series (i was able to convert to series from a list), essentially struggling to add a series and DF
You need to concatenate on
axis=1.Note that
concattakes alistofpandas.DataFrameorpandas.Seriesas the first argument.They
keysargument isn't necessary, unless you need hierarchical columns.