I have a DataFrame called ES_15M_Summary, with coefficients/betas in on column titled ES_15M_Summary['Rolling_OLS_Coefficient'] as follows:
If the above pictured column ('Rolling_OLS_Coefficient') is a value greater than .08, I want a new column titled 'Long' to be a binary 'Y'. If the value in the other column is less than .08, I want that value to be 'NaN' or just 'N' (either works).
So I'm writing a for loop to run down the columns. First, I created a new column titled 'Long' and set it to NaN:
ES_15M_Summary['Long'] = np.nan
Then I made the following For Loop:
for index, row in ES_15M_Summary.iterrows():
if ES_15M_Summary['Rolling_OLS_Coefficient'] > .08:
ES_15M_Summary['Long'] = 'Y'
else:
ES_15M_Summary['Long'] = 'NaN'
I get the error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
...referring to the if statement line shown above (if...>.08:). I'm not sure why I'm getting this error or what's wrong with the for loop. Any help is appreciated.
