Categories
Python Answers

How to create multiple dataframes in loop with Python Pandas?

Spread the love

Sometimes, we want to create multiple dataframes in loop with Python Pandas.

In this article, we’ll look at how to create multiple dataframes in loop with Python Pandas.

How to create multiple dataframes in loop with Python Pandas?

To create multiple dataframes in loop with Python Pandas, we can us dictionary comprehension.

For instance, we write

d = {name: pd.DataFrame() for name in companies}

to create a dict with data frames as values by looping through each entry in companies and using each companies entry as the key.

Conclusion

To create multiple dataframes in loop with Python Pandas, we can us dictionary comprehension.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *