I have a pandas dataframe that looks like this:
A B C D
0 1 2 3 0
1 4 5 6 1
2 7 8 9 2
3 10 10 10 0
4 10 10 10 1
5 1 2 3 0
6 4 5 6 1
7 7 8 8 2
I would like to remove all the set of rows that, in column 'D', are not -> 0,1,2 in this specific order;
The new dataframe I would like to obtain should look like this:
A B C D
0 1 2 3 0
1 4 5 6 1
2 7 8 9 2
3 1 2 3 0
4 4 5 6 1
5 7 8 8 2
.. because after row 3 and 4, row 5 did not have 2 in column 'D'.