I'm trying to convert the .values that I have into an array that has a function within it, but keep on coming up with an error. Would appreciate the help!
Here is the .values:
Y = df['GDP_growth'].values
array(['3.299991384', '-1.760010328', '5.155440545', '4.019541839',
'0.801760179', '7.200000003', '3.727818428', '0.883846197'], dtype-object)
Here is the command to make the array that comes out as an error:
Y = np.array([1 if y>= 3 else 0 for y in Y])
In my case, the error is that it all comes out as 1.