I would like to combine two datframe with same index number but different columns number like:
>>> df1
col_1 col_2 col_3 col_4
0 a x NaN 54
1 a y 5 34
2 b z NaN 64
3 c z 7 23
>>> df2
col_1 col_2 col_3 col_4 col_5
0 a x NaN 14 14
1 b z NaN 9 7
2 c z 7 51 53
3 a y 5 87 66
The df2
will combine in df1
based on the values of col_1
, col_2
andcol_3
.
But the order of the rows will not be the same.
I want to combine them based on the order of df1
And the answer will be like this:
col_1 col_2 col_3 col_4 col_4 col_5
0 a x NaN 54 14 14
1 a y 5 34 87 66
2 b z NaN 64 9 7
3 c z 7 23 51 53
I don't care about the column name, so you guys can modify them if you need.