Home > Back-end >  Unpack a list with many dataframes
Unpack a list with many dataframes

Time:04-27

I have a problem with a list containing many dataframes. I create them in that way:

listWithDf = []

listWithDf.append(file)

And I got:

enter image description here

And now I wanna work with data inside this list but I want to have one dataframe with all the data. I know this is a very ugly way and this must be changed every time the quantity of the dataframe is changed.

df = pd.concat([listWithDf[0], listWithDf[1], ...)

So, I was wondering is any better way to unpack a list like that. Or maybe is a different way to make some dataframe in a loop, which contains the data that I need.

CodePudding user response:

Here's a way you can do it as suggested in comments by @sjw:

df = pd.concat(listWithDf)

Here's a method with a loop(but it's unnecessary!):

df = pd.concat([i for i in listWithDf])
  • Related