Home > Blockchain >  How to merge 3 defferent comparative dataframes
How to merge 3 defferent comparative dataframes

Time:07-23

I have 3 seperate data frames which are; close_price_df, returns_df and volume_df of multiple symbols in comparison. I would like to merge them in order of close_price_df, returns_df and volume_df. How can I achieve that?.

Here are the data frames;

enter image description here

enter image description here

enter image description here

My expected result should be like the image below.

enter image description here

CodePudding user response:

Use pd.concat()


pd.concat([close_price_df, returns_df, volume_df], axis=1)

Edit:

Since 3 dataframes that merged all have the same columns, the column name for each df better be prefixed first to avoid some problem.


close_price_df.columns= ['close_price_' i for i in close_price_df.columns]
returns_df.columns= ['returns_' i for i in returns_df.columns]
volume_df.columns= ['volume_' i for i in volume_df.columns]

  • Related