concat two dataframe using python -
we have 1 dataframe like
-0.140447131 0.124802527 0.140780106 0.062166349 -0.121484447 -0.140675515 -0.002989106 0.13984927 0.004382326
and other
1 1 2
we need concat both dataframe like
-0.140447131 0.124802527 0.140780106 1 0.062166349 -0.121484447 -0.140675515 1 -0.002989106 0.13984927 0.004382326 2
let's first dataframe like
in [281]: df1 out[281]: b c 0 -0.140447 0.124803 0.140780 1 0.062166 -0.121484 -0.140676 2 -0.002989 0.139849 0.004382
and, second like,
in [283]: df2 out[283]: d 0 1 1 1 2 2
then create new column df1
using df2
in [284]: df1['d_new'] = df2['d'] in [285]: df1 out[285]: b c d_new 0 -0.140447 0.124803 0.140780 1 1 0.062166 -0.121484 -0.140676 1 2 -0.002989 0.139849 0.004382 2
the assumption being both dataframes have common index
Comments
Post a Comment