I have the following data frame:
| Y | Z |
-----------------
62 0
65 0
59 1
66 0
64 1
64 1
57 0
68 1
59 0
60 0
How can I filter out the Z column so, that all the "leftover values" after the final occurance of the value 1 will be filtered out (in this case all the zeroes after the last 1)? In the case of the above example, the filtered data frame would become:
| Y | Z |
-----------------
62 0
65 0
59 1
66 0
64 1
64 1
57 0
68 1
Also, how could I do the filtering for all the values before the first 1 (filter out all the values which precede it) ..?