2
$\begingroup$

I have three dataframes. Their shapes are (2656, 246), (2656, 2412) and (2656, 7025). I want to merge dataframes as above:

enter image description here

So It will result a (2656, 9683) Dataframe. Thanks for any help.

Typo on image: on Dataframe 3, it will 7025, not 5668.

$\endgroup$

1 Answer 1

4
$\begingroup$

Assuming that the rows are in same order that you wish to merge all of the dataframes, you can use the concat command specificying axis=1.

new_df = pd.concat([df1, df2, df3], axis=1)

If the row index for each of the data frames are different and you want to merge them in the current order, you can also apply ignore_index:

new_df = pd.concat([df1, df2, df3], ignore_index=True)

For details on the merge, join & concatenation operations, please refer to the pandas docs.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy