I tried to find a solution for this but I am not able to solve it. I have a list, with 7 elements, they are dataframes. Each of these elements have two columns. All I want to do is to have a single dataframe that contains all the columns from the list. I have attached two pictures, hopefully it explains better. About the picture, the list is on the left hand side and when I click on the first dataframe, the DataFrame editor on the right hands side opens. Each of the dataframes has two columns with 1000 data. I should end up with 14 columns with 1000 data. enter image description here
CodePudding user response:
you can combine DataFrame objects horizontally along the x axis by passing in axis=1
into pandas.concat
function (docs)
pd.concat(dataframe_list, axis=1)
CodePudding user response:
import pandas as pd
list of dataframes
df_list = [df1, df2, df3, df4, df5, df6, df7]
concatenate the dataframes along the columns axis
result = pd.concat(df_list, axis=1)