a quick one but I am a bit stuck on this. I have a dataframe with 3 classes: 0, 1, 2. The idea is to calculate cumsum per each class using, possibly, groupby, although there could be some other way.
Here is my df:
| classes |
| 1 |
| 0 |
| 1 |
| 2 |
| 1 |
| 2 |
| 0 |
| 0 |
The 'ID' column I'd like to see:
| classes | ID |
| 1 | 1 |
| 0 | 1 |
| 1 | 2 |
| 2 | 1 |
| 1 | 3 |
| 2 | 2 |
| 0 | 2 |
| 0 | 3 |
....etc...
Any ideas?