I have a spark Dataframe as follows,
+-------+-------+-----+
| s1 | s2 |isVal|
+-------+-------+-----+
|a |aa | 1|
|b |bb | 0|
|c |cc | 1|
|d |dd | 0|
|e |ee | 1|
+-------+-------+-----+
I want to check the isVal value in each row and if that value is equal to 1, that row should be split in to two rows.For ex: considering the first two rows of the above dataframe, result should be as follows,
+-------+-------+
| s1 | isVal|
+-------+-------+
|a | 1|
|aa | 1|
|b | 0|
+-------+-------+
Please help to build the logic using python. I have tried to build the logic using flatmap, but it did not deliver the expected result.