I have a dataframe called merged that looks like this. The index is placa_encoded.
placa_encoded codcet break
561.0 490101113 False
561.0 480481112 False
660.0 400081122 False
660.0 420121123 True
660.0 420141122 False
660.0 420151122 False
660.0 420171122 False
660.0 420171113 True
660.0 420161112 False
660.0 420151112 False
660.0 420121112 False
660.0 420111112 False
...
I'm looking for a dataframe that looks like this, chunked into groups indexed by each placa_encoded and at each point with break=True (aside from the very first group obviously) such that
placa_encoded codcet break
[561.0]
561.0 490101113 False
561.0 480481112 False
[660.0]
660.0 400081122 False
660.0 420121123 True
660.0 420141122 False
660.0 420151122 False
660.0 420171122 False
660.0 420171113 True
660.0 420161112 False
660.0 420151112 False
660.0 420121112 False
660.0 420111112 False
...
I've tried something like this so far, inspired by this answer, but it has not worked the way I want and instead grouped into buckets of True and False instead for each placa_encoded.
merged['ne'] = merged['break'].ne(merged['break'].shift()).cumsum()
merged.groupby(['placa_encoded', merged['ne']], sort=False)