Is there a way to split certain dataframe row so that I can make a group of rows with certain cumsum? In this example I want to split rows that makes cumsum 20
my data
timestamp counts cumsum
'2015-01-01 03:45:14' 4 4
'2015-01-01 03:45:14' 2 6
'2015-01-01 03:45:14' 1 7
'2015-01-01 03:45:15' 12 19
'2015-01-01 03:45:15' 8 27 <--split
'2015-01-01 03:45:15' 8 35
'2015-01-01 03:45:15' 2 37
'2015-01-01 03:45:16' 26 63 <--split(twice)
'2015-01-01 03:45:17' 3 66
'2015-01-01 03:45:17' 8 71
'2015-01-01 03:45:19' 11 82 <--split
'2015-01-01 03:45:20' 8 90
'2015-01-01 03:45:21' 1 91
I want my dataframe to be like this
my data
timestamp counts cumsum
'2015-01-01 03:45:14' 4 4
'2015-01-01 03:45:14' 2 6
'2015-01-01 03:45:14' 1 7
'2015-01-01 03:45:15' 12 19
'2015-01-01 03:45:15' 1 20 <--split 20
'2015-01-01 03:45:15' 7 27 <--split
'2015-01-01 03:45:15' 8 35
'2015-01-01 03:45:15' 2 37
'2015-01-01 03:45:16' 3 40 <--split 40
'2015-01-01 03:45:16' 20 60 <--split 60
'2015-01-01 03:45:16' 3 63 <--split
'2015-01-01 03:45:17' 3 66
'2015-01-01 03:45:17' 8 71
'2015-01-01 03:45:19' 9 80 <--split 80
'2015-01-01 03:45:19' 2 82 <--split
'2015-01-01 03:45:20' 8 90
'2015-01-01 03:45:21' 1 91