I have large dataframe and I want to substract this dataframe into smaller dataframes based on two conditions. Below is the small a piece of the dataframe:
| | id |outcome|
| ——– | ————– | |
| |1 | 0 |
| 0 | 1 | 1 |
| | 2 | 1 |
| 0 | 16 | 1 |
| | 3 | 1 |
| 0 | 5 | 1 |
| | 4 | 8 |
| 0 | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 16 | 1 |
I want to substract this dataframe into smaller dataframes based on typeId 16 and outcome 1 then take the row above untill outcome !=1. So to make it clear in the example above I should have two dataframes. The first one:
| 0 | 1 | 1 |
| | 2 | 1 |
| 0 | 16 | 1 |
and the second:
| 0 | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 1 | 1 |
| | 16 | 1 |
Thanks in advance.