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 use dictionary comprehension.
For instance, we write
d = {name: pd.DataFrame() for name in companies}
to create data frames with DataFrame
from the companies
list with with key name
with
{name: pd.DataFrame() for name in companies}
and assign the return data frame dictionary to d
.
Conclusion
To create multiple dataframes in loop with Python Pandas, we can use dictionary comprehension.