How to add a progress bar to Python with tqdm

preview_player
Показать описание
Learn how to add a cool progress bar to your Python process and iterations just in seconds!

How often are you doing Machine Learning iterations, long calculations or process that take a lot of time, with Python, and you have to wait for minutes? Right now, you don't know how much time is going to take to finish the task, so you could be waiting for 30 seconds, 4 minutes or 2 hours, without any indicator of how much is going to take.

That's it, until now.

In this video, you are going how to use the TQDM Python library to give your iterators a cool, customizable, cool progress bar that calculates how much time it's going to take.

╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬

Resources:
TQDM docs:

Pypi package:

╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬

Subscribe to the channel:

Text version:

Twitter:

GitHub:
Рекомендации по теме
Комментарии
Автор

once you hear and learn about tqdm, you will use it in every script ever...
so simple to implement yet so helpful

also, if you have an iteration using zip, you need to add the total argument. For example

for i, j in tqdm(zip(list1, list2)): --- won't work, use this instead

for i, j in tqdm(zip(list1, list2), total=len(list1)):

alexradu
Автор

Very good your class, I tried to make a similar one. but it is blocking the presentation of the progress bar, see that the program runs the numbers, but the bar does not appear at the beginning and when it is at the end it ends, it does not do it in real time, which would be the goal. have you ever seen something like this? could you tell me where the error is? or would it be better to use another Progressbar package? I will put the code below:
import itertools
import time
from tqdm import tqdm_gui

inicio = time.time()
contador = 0
stuff = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]

for i in tqdm_gui(range(4, len(stuff)+1)):
for subset in itertools.combinations (stuff, i):
if contador == 10000:
break
print(subset)
contador = contador + 1

fim = time.time()
tempo = fim - inicio
print ("O Tempo para gerar os numeros foi de ", tempo)
print ("O total de combinações foi", contador)

telmomachado
Автор

Hi everyone, I'm trying to make a dynamic progress bar: the iterable is a list of a dynamic size. I.e. the list grows with every iteration. How can make the the progress bar get updated with every iteration? If anyone knowns, please let me know.

kareemjeiroudi
Автор

I typed the same code but I do not get a progress bar...I get only the percentage and lots of outputs

gauravarora