How to merge 3 defferent comparative dataframes

Question:

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

Asked By: Jamiu Shaibu

||

Answers:

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]

Answered By: zousan
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.