Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python tqdm package - how to configure for less frequent status bar updates

I'm using a tqdm package (v4.19.5) for a loop with 200K+ iterations in Python 3.6 (Anaconda 3, Windows 10 x64, PyCharm IDE). It prints the status bar too frequently, so that my earlier history disappears in the console.

Is there a way to limit the frequency of status bar updates? I can't seem to find this solution online or tqdm website.

Currently, my status bar prints like this. Ideally, I'd like to set put a cap on percentage change. For example, update it not more frequently than once per 1% change/progress.

enter image description here

like image 940
Oleg Melnikov Avatar asked Dec 27 '17 17:12

Oleg Melnikov


People also ask

How to make progress bar in tqdm in Python?

Python tqdm With GUI You can also make the progress bar with GUI which can surely help you understand better about the progress. Python tqdm library has a separate function ‘tqdm_gui’ for this task with almost the same function just different names and Interface.

What is tqdm in Python?

tqdm is a Python library that allows you to output a smart progress bar by wrapping around any iterable. A tqdm progress bar not only shows you how much time has elapsed, but also shows the estimated time remaining for the iterable. Since tqdm is part of the Python Package Index ( PyPI ), it can be installed using the pip install tqdm command.

What does update (0) do in tqdm?

Using update (0) is a handy way to let tqdm decide when to trigger a display refresh to avoid console spamming. This is a work in progress (see #737 ). Since tqdm uses a simple printing mechanism to display progress bars, you should not write any message in the terminal using print () while a progressbar is open.

How to use Python tqdm with pandas data frame?

We first import the tqdm module which is expected to receive an iterable object in it. In this specific example, we’ve used the range() function to provide an iterable for tqdm. You can use any iterable according to your need. Then we mapped the tqdm object with an str() function to get the result. Integrating Pandas Data Frame and Python tqdm 


1 Answers

You can use miniters parameter i have it from source code https://github.com/tqdm/tqdm/blob/master/tqdm/_tqdm.py

tqdm.tqdm(iterable, miniters=int(223265/100))
like image 168
miroB Avatar answered Sep 24 '22 07:09

miroB