0

So I have two dataframes, in pandas:

x = pd.DataFrame([[1,2],[3,4]])
>>> x
   0  1
0  1  2
1  3  4
y = pd.DataFrame([[7,8],[5,6]])
>>> y
   0  1
0  7  8
1  5  6

Clearly they are the same size. Now it seems you can do merges and joins on a selected column, but I can't seem to do it on an index. I want the outcome to be as:

   0  1  2  3
0  7  8  1  2
1  5  6  3  4
redrubia
  • 2,256
  • 6
  • 33
  • 47

1 Answers1

5

How about:

>>> x = pd.DataFrame([[1,2],[3,4]])
>>> y = pd.DataFrame([[7,8],[5,6]])
>>> df = pd.concat([y,x],axis=1,ignore_index=True)
>>> df
   0  1  2  3
0  7  8  1  2
1  5  6  3  4

[2 rows x 4 columns]
DSM
  • 342,061
  • 65
  • 592
  • 494