I have two data frames df1 and df2 and I would like to merge them into a single data frame. It is as if df1 and df2 were created by splitting a single data frame down the center vertically, like tearing a piece of paper that contains a list in half so that half the columns go on one paper and half the columns go on the other. I would like to merge them back together. How do I do it?
Pandas has a built-in merge function. Please refer to the documentation
End-result should be something like this: df_merged = pd.merge(df1, df2, left_on=['name_indexcolumn_df1_here'], right_on=['name_indexcolumn_df2_here'], how='inner')
If you split the DataFrame "vertically" then you have two DataFrames that with the same index.
You can use the merge function or the concat function.
With concat with would be something like this:
With merge with would be something like this:
For more complex merging options see the Merge, join and concat pandas tutorial.