I have the following dataframe:
| Class | Received | Issued |
|---|---|---|
| FD | 10 | 0 |
| FD | 0 | 2 |
| RM | 5 | 0 |
| RM | 0 | 3 |
| FD | 0 | 2 |
| PM | 5 | 0 |
| PM | 1 | 0 |
| RM | 1 | 0 |
| FD | 4 | 0 |
I require the dataframe below:
| Class | Received | Issued | Remaining Quantity |
|---|---|---|---|
| FD | 10 | 0 | 10 |
| FD | 0 | 2 | 8 |
| RM | 5 | 0 | 5 |
| RM | 0 | 3 | 2 |
| FD | 0 | 2 | 6 |
| PM | 5 | 0 | 5 |
| PM | 1 | 0 | 6 |
| RM | 1 | 0 | 3 |
| FD | 4 | 0 | 10 |
The remaining quantity column is cumsum() of received - issued per class. I have tried different methods but I'm not getting it.
Output: