I have dataframe df that looks like this
Lvl Distance iMap Grp
0 37 63 A3 1
1 37 59 A9 1
2 37 54 A3 2
3 37 48 A4 2
...
190 37 27 A3 1
191 37 20 A3 4
I have 2 filters that I am trying to combine with "OR"
The first is m1
m1 = df[(df["Distance"]<55)].groupby('Grp').cumcount().eq(0)
you notice that m1 index starts with 2 (not 0)
>>> m1
2 True
3 False
4 False
...
187 True
188 False
189 False
190 False
191 False
also the 2nd filter
m2 = df['Distance'].gt(55)
you notice that m2 index starts with 0
>>> m2
0 True
1 True
2 False
3 False
4 False
...
187 False
188 False
189 False
190 False
191 False
When I try to combine both filters
df[m1 | m2]
and results
Lvl Distance iMap Grp
2 37 54 A3 2
19 37 41 A4 3
74 37 36 A3 1
187 37 29 A3 4
you can see that the first 2 records were not selected although their value is True in m2
but that value does not exist in m1
any idea how to fix this? so if any index is True it shows
