I am using the below code.
for x in range(100):
print('inside 1st loop')
for y in range(25,60):
print('inside second loop')
if y >= x:
print ('y is now greater than x')
Is it possible that once the if condition is satisfied in the inner for loop, the outer loop breaks itself, after 5 more inner loops are run.
Actual code is as below :
for i in range(len(a1)):
title_derived = []
print(i)
for j in range(len(b1)):
#print(b1.iloc[i][10], a1.iloc[j][3])
if b1.iloc[j][10] == a1.iloc[i][3]:
print('1st if ' + str(j))
print (b1.iloc[j][1], a1.iloc[i][11], b1.iloc[j][5])
if (((pd.to_datetime(b1.iloc[j][1]) <= pd.to_datetime(a1.iloc[i][11]) <= pd.to_datetime(b1.iloc[j][5]))) or ((pd.to_datetime(b1.iloc[j][1]) <= pd.to_datetime(a1.iloc[i][8]) <= pd.to_datetime(b1.iloc[j][5])))) :
print('2nd if' + str(j))
title_derived.append(b1.iloc[j][15])
print('inserted ' + b1.iloc[j][15] + ' in ' + str(i) + ' th record ')
a1.iat[i,65] = title_derived
Now here, I have two dataframes, each record in first (10000 approx records) looks up every record in other dataframe (40000 records). Sometimes there can be atmost 4-5 consecutive entries that match the condition.
So, once the condition is satsfied in second loop, I would like to finish five more iterations and break it.