Hi I try to create new column "state" based on this function:
def state (row):
if (np.sign(row) == np.sign(row).shift(1)) and (row > 1):
return 1
elif (np.sign(row) == np.sign(row).shift(1)) and (row < -1):
return -1
elif (np.sign (row) == np.sign(row).shift(1)) :
return (row).shift(1)
else:
return 0
After applying the function on dataset by this code:
data['state'] = data['zscore'].apply(state)
I got the error: 'numpy.float64' object has no attribute 'shift'.
Any suggestion will be greatly appreciated,