I have taken a specific list from a larger dataset and would like to assign the value of 0 to negative numbers and 1 to numbers >= 0.
This code gave me the specific list from the larger dataset
r = data[['return']]
r.head()
This is the code I have already tried to accomplish what I wanted
for num in r:
if num >= 0:
num = 1
else:
num = 0
It did not work and instead said that "'>=' not supported between instances of 'str' and 'int'"