'How to split pandas dataframe into multiple dataframes (holding together rows) based upon a column's value
My problem is similar to split a dataframe into chunks of N rows problem, expect that the number of rows in each chunk will be different. I have a datafame as such:
A | B | C |
---|---|---|
1 | 2 | 0 |
1 | 2 | 1 |
1 | 2 | 2 |
1 | 2 | 0 |
1 | 2 | 1 |
1 | 2 | 2 |
1 | 2 | 3 |
1 | 2 | 4 |
1 | 2 | 0 |
A and B are just whatever don't pay attention. Column C though starts at 0 and increments with each row until it suddenly resets to 0. So in the dataframe included the first 3 rows are a new dataframe, then the next 5 are a second new dataframe, and this continues as my dataframe adds more and more rows.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|