I'm new to Pandas, the answer may be obvious.
I have 3 series of the same length: a, b, c
a[b > c] = 0
works, but:
a[math.fabs(b) > c] = 0
doesn't work, and
a[(b > c or b < -c)] = 0
doesn't work either.
How can I implement that logic?
I'm new to Pandas, the answer may be obvious.
I have 3 series of the same length: a, b, c
a[b > c] = 0
works, but:
a[math.fabs(b) > c] = 0
doesn't work, and
a[(b > c or b < -c)] = 0
doesn't work either.
How can I implement that logic?
Your issue is that in the first expression the expression you use is vectorized while in the other one it is not.
<
operation between two series returns a series as wellmath.fabs
is supposed to be applied elements by elements and not to an array/series of elements (try the numpy version instead is it exists). or
operation is not vectorized and you should use |
instead.