I have the following example data, and I'd like to filter a piece of data, when (col1 = 'A' and col2 = '0') we want to keep rows until next (col1 = 'A').
I want to do using pandas dataframe but I don't know how it is.
df = pd.DataFrame({'col1': ['A', 'B', 'C'], 'col2': [0, 1]})
For example, we have this data
col1 col2
A 0
C
A 1
B
C
A 1
B
B
C
A 0
B
C
A 1
B
C
C
The result I want to achieve is:
col1 col2
A 0
C
A 0
B
C
Thank you very much