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 DataFrame
s 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:
df_compare = pd.concat([df1, df2], axis=1, join='outer')
If you only want to keep values where both DataFrame
s have some value, use join='outer'