I am running the following code:
def backwash (df):
df.loc[0, 'backwash'] = np.NaN
for i in range (3, len(df)-2):
while (df.loc[i,'MF1 Permeate Flow (m3/min)']==0):
if (df.loc[i-2:i+2, 'MF1 Trans-Membrane Pressure (kPa) (PDI3423)']>0):
df.loc[i,'backwash'] = 'BW'
break
else:
break
else:
pass
return df
The problem is with df.loc [i-2:i+2, 'MF1 Trans-Membrane Pressure (kPa) (PDI3423)']
. Hence I get the Value error (the truth value is ambiguous). Is there any other way to run this loop?
I essentially want to check the value on certain row based on the value of previous and following two rows.