I have a dataframe of 12 columns, one column is just boolean; showing whether the given condition (dependent on other columns) is satisfied or not. That column is called "normality". I am trying to delete the rows of False values only if the row before and the row after that are True.
for s in range((dfm['normality'].count())):
if dfm.loc[[s],('normality')] == False:
if ((dfm.loc[[s+1],('normality')]) == True) & ((dfm.loc[[s-1],('normality')]) == True):
dfm=dfm.drop(dfm.index[s])
else:
;
I have tried to use this code, yet I constantly get the error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
on line 7 (the first if statement).
Any help would be appreciated, thank you.
Aucun commentaire:
Enregistrer un commentaire