Jan-06-2019, 12:36 AM
I have 3 columns in question... ['Last'] is data... ['Goal'] is Last shifted forward 5 rows
I am trying to assign a value to ['direction'] based on ['Goal'} >< 5
I'm probably over-complicating things, any help?
I am trying to assign a value to ['direction'] based on ['Goal'} >< 5
I'm probably over-complicating things, any help?
# I begin with creating a zero column as I was getting length errors data['direction'] = 0 data['Goal'] = data['Last'].shift(5) data = data.dropna() #Drop rows with NAN after shift for row in data.Last: if (data.values['Goal'] - data.values['Last'] >= 5): data['direction'] = 1, elif (data.values['Goal'] - data.values['Last'] <= -5): data['direction'] = -1, else: data['direction']=0
Error:IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices