Search code examples
pythonpython-3.xpandasdataframeconcatenation

How to concatenate efficiently a list of dataframes?


I have a function crawl that input an integer and output a dataframe. To concatenate dataframes df1, df2, df3, we can use pandas.concat([df1, df2, df3]). I would like to ask of there is an efficient way to concatenate df1,..., df17 without writing a long list df1 = crawl(1),..., df17 = crawl(17).

Thank you so much!


Solution

  • How about:

    pd.concat([crawl(i) for i in range(1,18)])