Reputation: 2870
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!
Upvotes: 3
Views: 967
Reputation: 34086
You can do this:
df_list = [crawl(i) for i in range(1,18)]
final_df = pd.concat(df_list)
Upvotes: 1