Menu Close

How to split dataframe into multiple dataframes with Python Pandas?

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.

Posted in Python, Python Answers