I'm looking for a simple and neat way to check if a variable is positive where this can be either a float or a numpy.timedelta64
or datetime.timedelta
.
I obviously tried x>0
, but this doesn't work for timedelta
s (neither numpy
's or datetime
's)
The only solution i found is x/abs(x) > 0
that I find somehow cumbersome. Not even np.sign
returns an answer.
Is there a better way to check this?
EDIT:
Using x.total_seconds()
returns an error whenever x
is a float. Using x > np.timedelta(0)
does not work for datetime.timedelta
s.