I am trying to generate a pandas dataframe column from a logical operation between elements of three other columns. I know I can slog through it row by row but I am sure there is a neater way to implement this. Below is what I would do if standard operations worked between dataframe columns (obviously this code does not work). The operation relies on accessing the previous value in that column, hence the .shift() in the last line.
if dataframe['C'] > dataframe['H']:
dataframe['Result'] = 1
else:
if dataframe['C'] < dataframe['L']:
dataframe['Result'] = -1
else:
dataframe['Result'] = dataframe['Result'].shift()