I have the following dataframe:
limit1 limit2
a 123 567
b 65 0
c 123 1233
d 0987 0
e 231451 0998
I want to create a new frame with the lower limit for each row. Except when there is a 0, in which case the value from the other column is taken.
desired output:
limit1 limit2
a 123 567
b 65 65
c 123 1233
d 0987 0987
e 231451 0998
As you can see the 0 on the right are replaced with the value from the corresponding row from the left.
My following code does not work:
low_limit = pd.concat([limit1, limit2], join='outer', axis=1)
if limit2 == 0:
low_limit = limit1
else:
low_limit.min(axis=1).dropna()
the error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().