I have a dataset that contains a column 'y' in which a particular values exist. I would like to take that column and make a new column (z) denoting if y value is 47472 then z should be 1000, if y <1000 then z=y*2, else all other values should be 2000. Here's a mock example of the data. I don't have a 'z' column, but I want to create it:
y z
0 1751 2000
1 800 1600
2 10000 2000
3 350 700
4 750 1500
5 1750 3500
6 30000 2000
7 47472 1000
def test(y):
if y == 47472:
z=1000
elif y < 1000:
z=y*2
else:
z=2000
return Z
# I tried to call the above function below
z = test(y)
z
but I don't get the result instead it shows below error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
y?yis here. From the error, it appears to be a Series, not an integer.