It's my first time using python and pandas (plz help this old man). I have a column with float and negative numbers and I want to replace them with conditions. I.e. if the number is between -2 and -1.6 all'replace it with -2 etc. How can I create the condition (using if else or other) to modify my column. Thanks a lot
mean=[]
for row in df.values["mean"]:
if row <= -1.5:
mean.append(-2)
elif row <= -0.5 and =-1.4:
mean.append(-1)
elif row <= 0.5 and =-0.4:
mean.append(0)
else:
mean.append(1)
df = df.assign(mean=mean)
Doesn't work