I have a dataframe pd
. I would like to change a value of column irr
depending on whether it is above or below a thresh hold.
How can I do this in a single line? Now I have
pd['irr'] = pd['irr'][pd['cs']*0.63 > pd['irr']] = 1.0
pd['irr'] = pd['irr'][pd['cs']*0.63 <= pd['irr']] = 0.0
The problem of course is that I change irr
and check it again in the next line.
Is there something like a ternary conditional operator for pandas?