How to combine two pandas DataFrames with the same index
If you have two pandas DataFrames you want to join where the index in both DataFrames are and you want to obtain a DataFrame where the respective columns are set to NaN if there is no value from the respective DataFrame, this is typically the correct way to do it:
concat_dataframes.py
df_compare = pd.concat([df1, df2], axis=1, join='outer')If you only want to keep values where both DataFrames have some value, use join='outer'
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow