Categories
Python Answers

How to split dataframe into multiple dataframes with Python Pandas?

Spread the love

To split dataframe into multiple dataframes with Python Pandas, we can use list comprehension with groupby.

For instance, we write

[v for k, v in df.groupby('name')]

to call df.groupby with 'name' to group by the name column and then we get the split data frames from value v with the data frames with the grouped items separated.

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 *