I have the following framework:
df =
ID TYPE VD_0 VD_1 VD_2 VD_3
1 ABC V1234 456 123 564
2 DBC 456 A45 123 564
3 ABD 456 V1234 456 123
4 ABD 123 V1234 SSW 123
Below is a list of values VD_0, VD_1, VD_2and VD_3:
myList = [V1234,456,A45]
I want to get only those rows in dfwhich have 2 sequential events of the values myListin the columns VD_0, VD_1, VD_2and VD_3.
The result is the following:
result =
ID TYPE VD_0 VD_1 VD_2 VD_3
1 ABC V1234 456 123 564
2 DBC 456 A45 123 564
3 ABD 456 V1234 456 123
For example, in a line with ID1, the values of VD_0and VD_1are equal V1234and 456, accordingly, both of these values belong myList. The same logic applies to rows with ID2 ( 456, A45) and 3 ( 456, V1234).
How can i do this?