Reputation: 89
I've having an issue checking is a value is in the following dataframe:
index | open | high | SignalEMA25M50M | PositionEMA25M50M |
---|---|---|---|---|
2021-03-30 05:35:00 | 0.000059 | 0.000059 | 0 | -1.0 |
2021-03-30 05:40:00 | 0.000059 | 0.000059 | 0 | 0.0 |
2021-03-30 05:45:00 | 0.000059 | 0.000059 | 0 | 0.0 |
i am trying to simply return true if the PositionEMA25M50M contains -1.0
i have tried:
if -1.0 in indicator_5min_df.PositionEMA25M50M:
print('true')
else:
print('false')
however this returns false every time... i assume this is something to do with PositionEMA25M50M being of type float64 however i've also tried
if np.float64(-1.0) in indicator_5min_df.PositionEMA25M50M:
print('true')
else:
print('false')
which has given me the same result...
any ideas how i can fix this?
Upvotes: 0
Views: 3736
Reputation: 34086
You don't need a if
loop. You can directly use Series.eq
with any
to check if any row has -1
for this column:
In [990]: df['PositionEMA25M50M'].eq(-1).any()
Out[990]: True
Upvotes: 1