I'm looping through a DataFrame and want to check whether three conditions are met in the previous 150 records but not the last 30 or so.
The columns I'm wanting to check are TRAJ50_1, TRAJ100_1, TRAJ200_1 (where all have values less than 0)
I'm currently trying the following:
for i in range(len(values)):
if i > 0:
if data.loc[i-150:i-30, (data['TRAJ50_1'][i] < 0) & (data['TRAJ100_1'] < 0) & (data['TRAJ200_1'] < 0)]:
_recent_decline = 1
else:
_recent_decline = 0
This is resulting in the following error:
pandas.core.indexing.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).
I've spent hours searching but as a relative newbie to Python its a tad confusing. Thank you in advance.