fig = plt.figure(num=1, clear=True) for i in tqdm(range(55238, len(df)-40)): df_tmp = df.iloc[i:i+30] name = f'data/{i+30+1}' generate_picture(df_tmp, name, fig) gc.collect()