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.