Issue
I want to use a manual progress bar from tqdm in a Jupyter notebook with a nested loop. To have an overview over all iterations, I use a manual update of the progress bar as follows:
from tqdm.notebook import tqdm
a = range(100)
b = range(5)
pbar = tqdm(total=len(a)*len(b))
for a_ in a:
for b_ in b:
pbar.update(1)
pbar.refresh()
However, when the total number of iterations is reached (i.e., 100%), the color is still blue. But if I use something like for i in trange(100): ...
, the progress bar turns green after finishing.
Can someone tell me how to achieve the same behavior for the manual progress bar? Thanks for help!
Solution
I think pbar.close() can do it.
from tqdm.notebook import tqdm
a = range(100)
b = range(5)
pbar = tqdm(total=len(a)*len(b))
for a_ in a:
for b_ in b:
pbar.update(1)
pbar.refresh()
pbar.close()
Answered By - Oivalf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.