I have a situtation like that with this Spark dataframe:
| id | value |
|---|---|
| 1 | 0 |
| 1 | 3 |
| 2 | 4 |
| 1 | 0 |
| 2 | 2 |
| 3 | 0 |
| 4 | 1 |
Now what I want to obtain is to efficiently split this single dataframe in 3 different one such that each dataframe extracted from the original one is between two 0 in the "value" column (with the first zero indicating the beginning of each dataframe) using Apache Spark, so that I would obtain this as result:
Dataframe 1 (rows from first 0 value to the last value before the next 0):
| id | value |
|---|---|
| 1 | 0 |
| 1 | 3 |
| 2 | 4 |
Dataframe 2 (rows from the second zero value to the last value before the 3rd zero):
| id | value |
|---|---|
| 1 | 0 |
| 2 | 2 |
Dataframe 3:
| id | value |
|---|---|
| 3 | 0 |
| 4 | 1 |