Search code examples
pandasjoinmergeconcatenation

Combining multiple Dataframes in pandas with common column names


I have 7 dataframes which look like this:

name sub amount
a     b    5

name sub amount
a     b    10

name sub amount
a     b    63

name sub amount
a     b    85

name sub amount
a     b    4

. . .

I want them to look like this:

amount
5
10
63
85
4
.
.

i tried:

frames = [df1, df2, df3, df4, df5, df6, df7]
result = pd.concat(frames)

but the result shows diagonal combined dataframes with nan.

anyone who can help?


Solution

  • frames = [df1['amount'], df2['amount'], df3['amount'], df4['amount'], df5['amount'], df6['amount'], df7['amount']]
    result = pd.concat(frames, ignore_index=True)