I have created a dataframe (boolean values) from a timeseries which (true on a certain date if value is above x, false if value is below). I am trying to loop into this dataframe- whenever I encounter a true value I want to update the counter; if false I want to break and print the updated counter. It looks like this, but the while loop does not break - any ideas of what I am missing here? Thanks in advance
k=0
dataa='2019-11-01'
for index in df_resz[dataa:].iterrows():
while (df_resz.loc[dataa,'bool_resz']==True):
k=k+1
else:
break
print (k)
editto add the tag) - Nick Parsonsdf_resz.loc[dataa,'bool_resz']ever change fromTruetoFalseonce you're inside thewhileloop??? Also, yourbreakstatement would technically end theforloop if it is ever reached, so why have aforloop to begin with??? - goodvibration