Please consider this data frame:
date value
-------------------
20201001 -100
20200202 200
20200303 0
...
I want to hav1e another very simple column: "Status"
if Value < 0 Then "Status" = -1
if Value > 0 Then "Status" = 1
if Value = 0 Then "Status" = 0
I wrote this code:
data['Status'] = (data['Value'] / math.fabs(data['Value'])) if data['Value'] != 0 else 0
but I got this error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
How to create this column without For loop. Thanks
Edit 1) I wrote the code this way but I got same error:
data['Status'] = (data['Value'] / math.fabs(data['Value'])) if data[data['Value'] != 0] else 0