Hi I have a datframe that look like this
Date Col1 Col2 Col3 col4
0 1-4-2020 a ed kv sc sf ds n
1 1-4-2020 b hed sf ed df hed c
2 1-4-2020 c df xz sf sf ds n
3 2-4-2020 a ed df hed sf ds n
4 2-4-2020 b gv bb sc s ds c
5 2-4-2020 c ed sf sc hed ds n
What I want to do is to filter the rows with multiple conditions. If:
- Tow rows have the same value in Col1. For example a == a
- And they have the same values in Col4. n==n
- If both conditions are true search Col2 and Col3 for the key strings "hed" and "sf". they can be in Col2 or Col3(or both)
So the result will look like this:
Date Col1 Col2 Col3 col4
1 1-4-2020 b hed sf ed df hed c
3 2-4-2020 a ed df hed sf djs n
5 2-4-2020 c ed sf ssc hed djs n
I hope it is clear Update
In case Col4
Date Col1 Col2 Col3 col4
0 1-4-2020 a ed kv sc sf ds n
1 1-4-2020 b hed sf ed df hed c
2 1-4-2020 c df xz sf sf ds n
3 1-4-2020 d df xdg sf sf hed y
4 2-4-2020 a ed df hed sf ds n
5 2-4-2020 b gv bb sc s ds c
6 2-4-2020 c ed sf sc hed ds n
7 2-4-2020 d df xgfgf gf gfd null
In case that the value in Col4 appears only once in the dataframe like in row 3 (hint no next row to compare with) the function should return the row.
Date Col1 Col2 Col3 col4
1 1-4-2020 b hed sf ed df hed c
3 1-4-2020 d df xdg sf sf hed y
4 2-4-2020 a ed df hed sf ds n
6 2-4-2020 c ed sf sc hed ds n