I'm developing a script to check if a data frame's column's sum is over three with a certain interval.
loc_number = 10 # start loc image number with 10
k = 2
while k < 3:
for i in range(0, int(len(target_df.index)/loc_number), loc_number):
print(range(0, int(len(target_df.index)/loc_number), loc_number))
print(loc_number, i)
loc_target_df = target_df.loc[i: i+loc_number].sum(skipna=True, axis=0)
print(loc_target_df)
if any(x < 3 for x in loc_target_df):
loc_number += 1
print('heloo')
break
else:
print('here')
pass
print('probably')
continue
It seems at the beginning, it goes to 'if' and print out 'heloo' for a while, which means the sum of the certain column's values isn't over three. Ok. it's what I wanted.
However, when it goes to else, which means the cloumn's sum is over three, it should go to next 'for loop' not 'while'. but it goes to while loop again and again, so print out like this:
here
probablay
range(0, 14, 322)
322 0
10.000000 272
26.400000 210
31.680000 106
38.016000 113
45.619200 215
54.743040 146
65.691648 224
78.829978 255
94.595973 321
113.515168 308
136.218201 356
163.461842 270
196.154210 190
235.385052 97
282.462062 47
338.954475 32
406.745370 6
488.094443 3
dtype: int64
here
probablay
range(0, 14, 322)
322 0
10.000000 272
26.400000 210
31.680000 106
38.016000 113
45.619200 215
54.743040 146
65.691648 224
78.829978 255
94.595973 321
113.515168 308
136.218201 356
163.461842 270
196.154210 190
235.385052 97
282.462062 47
338.954475 32
406.745370 6
488.094443 3
dtype: int64
here
probablay
range(0, 14, 322)
322 0
10.000000 272
26.400000 210
31.680000 106
38.016000 113
45.619200 215
54.743040 146
65.691648 224
78.829978 255
94.595973 321
113.515168 308
136.218201 356
163.461842 270
196.154210 190
235.385052 97
282.462062 47
338.954475 32
406.745370 6
488.094443 3
dtype: int64
here
probablay
range(0, 14, 322)
322 0
what's the problem of my while for loop ?? and how to make the for loop work?
kanywhere inside the while looppassthere, because it literally does nothing.