I would like to check if is there any value different than zero and different than NaN in a dataframe column. I was using the following method but is not working quite right now.
if ts.any((ts['x'] > 0) || (ts['x'] < 0)):
bool = True
or
if ts.any((ts['x'] > 0) || (ts['x'] < 0)):
bool = True
Any tips of how should I proceed ?
Use |
for bitwise OR
or &
for bitwise AND
with any
:
if ((ts['x'] > 0) | (ts['x'] < 0)).any():
Or:
if ((ts['x'] != 0) & (ts['x'].notnull())).any():