auto
Enables multiple commonly used features.
Method resolution order:
tqdm.autonotebook without import warnings
tqdm.asyncio on Python3.6+
tqdm.std base class
Usage: >>> from tqdm.auto import trange, tqdm >>> for i in trange(10): ... ...
Classes
Decorate an iterable object, returning an iterator which acts exactly |
Functions
|
- class tqdm(iterable=None, desc=None, total=None, leave=True, file=None, ncols=None, mininterval=0.1, maxinterval=10.0, miniters=None, ascii=None, disable=False, unit='it', unit_scale=False, dynamic_ncols=False, smoothing=0.3, bar_format=None, initial=0, position=None, postfix=None, unit_divisor=1000, write_bytes=None, lock_args=None, nrows=None, colour=None, delay=0, gui=False, **kwargs)
Bases:
conda._vendor.tqdm.utils.Comparable
Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested.
- property _comparable
- property format_dict
Public API for read-only member access.
- monitor_interval = 10
- monitor
- _instances
- static format_sizeof(num, suffix='', divisor=1000)
Formats a number (greater than unity) with SI Order of Magnitude prefixes.
- static format_interval(t)
Formats a number of seconds as a clock time, [H:]MM:SS
- static format_num(n)
Intelligent scientific notation (.3g).
- static status_printer(file)
Manage the printing and in-place updating of a line of characters. Note that if the string is longer than a line, then in-place updating may not work (it will print a new line at each refresh).
- static format_meter(n, total, elapsed, ncols=None, prefix='', ascii=False, unit='it', unit_scale=False, rate=None, bar_format=None, postfix=None, unit_divisor=1000, initial=0, colour=None, **extra_kwargs)
Return a string-based progress bar given some parameters
- Parameters
total (int or float) -- The expected total number of iterations. If meaningless (None), only basic progress statistics are displayed (no ETA).
elapsed (float) -- Number of seconds passed since start.
ncols (int, optional) -- The width of the entire output message. If specified, dynamically resizes {bar} to stay within this bound [default: None]. If 0, will not print any bar (only stats). The fallback is {bar:10}.
prefix (str, optional) -- Prefix message (included in total width) [default: '']. Use as {desc} in bar_format string.
ascii (bool, optional or str, optional) -- If not set, use unicode (smooth blocks) to fill the meter [default: False]. The fallback is to use ASCII characters " 123456789#".
unit (str, optional) -- The iteration unit [default: 'it'].
unit_scale (bool or int or float, optional) -- If 1 or True, the number of iterations will be printed with an appropriate SI metric prefix (k = 10^3, M = 10^6, etc.) [default: False]. If any other non-zero number, will scale total and n.
rate (float, optional) -- Manual override for iteration rate. If [default: None], uses n/elapsed.
bar_format (str, optional) --
Specify a custom bar string formatting. May impact performance. [default: '{l_bar}{bar}{r_bar}'], where l_bar='{desc}: {percentage:3.0f}%|' and r_bar='| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, '
'{rate_fmt}{postfix}]'
- Possible vars: l_bar, bar, r_bar, n, n_fmt, total, total_fmt,
percentage, elapsed, elapsed_s, ncols, nrows, desc, unit, rate, rate_fmt, rate_noinv, rate_noinv_fmt, rate_inv, rate_inv_fmt, postfix, unit_divisor, remaining, remaining_s, eta.
Note that a trailing ": " is automatically removed after {desc} if the latter is empty.
postfix (*, optional) -- Similar to prefix, but placed at the end (e.g. for additional stats). Note: postfix is usually a string (not a dict) for this method, and will if possible be set to postfix = ', ' + postfix. However other types are supported (#382).
unit_divisor (float, optional) -- [default: 1000], ignored unless unit_scale is True.
initial (int or float, optional) -- The initial counter value [default: 0].
colour (str, optional) -- Bar colour (e.g. 'green', '#00ff00').
- Returns
out
- Return type
Formatted meter and stats, ready to display.
- classmethod _get_free_pos(instance=None)
Skips specified instance.
- classmethod _decr_instances(instance)
Remove from list and reposition another unfixed bar to fill the new gap.
This means that by default (where all nested bars are unfixed), order is not maintained but screen flicker/blank space is minimised. (tqdm<=4.44.1 moved ALL subsequent unfixed bars up.)
- classmethod write(s, file=None, end='\n', nolock=False)
Print a message via tqdm (without overlap with bars).
- classmethod external_write_mode(file=None, nolock=False)
Disable tqdm within context and refresh tqdm when exits. Useful when writing to standard output stream
- classmethod set_lock(lock)
Set the global lock.
- classmethod get_lock()
Get the global lock. Construct it if it does not exist.
- classmethod pandas(**tqdm_kwargs)
- Registers the current tqdm class with
pandas.core. ( frame.DataFrame | series.Series | groupby.(generic.)DataFrameGroupBy | groupby.(generic.)SeriesGroupBy ).progress_apply
A new instance will be create every time progress_apply is called, and each instance will automatically close() upon completion.
- Parameters
tqdm_kwargs (arguments for the tqdm instance) --
Examples
>>> import pandas as pd >>> import numpy as np >>> from tqdm import tqdm >>> from tqdm.gui import tqdm as tqdm_gui >>> >>> df = pd.DataFrame(np.random.randint(0, 100, (100000, 6))) >>> tqdm.pandas(ncols=50) # can use tqdm_gui, optional kwargs, etc >>> # Now you can use `progress_apply` instead of `apply` >>> df.groupby(0).progress_apply(lambda x: x**2)
References
<https://stackoverflow.com/questions/18603270/ progress-indicator-during-pandas-operations-python>
- __bool__()
- __nonzero__()
- __len__()
- __enter__()
- __exit__(exc_type, exc_value, traceback)
- __del__()
- __str__()
Return str(self).
- __hash__()
Return hash(self).
- __iter__()
Backward-compatibility to use: for x in tqdm(iterable)
- update(n=1)
Manually update the progress bar, useful for streams such as reading files. E.g.: >>> t = tqdm(total=filesize) # Initialise >>> for current_buffer in stream: ... ... ... t.update(len(current_buffer)) >>> t.close() The last line is highly recommended, but possibly not necessary if t.update() will be called in such a way that filesize will be exactly reached and printed.
- close()
Cleanup and (if leave=False) close the progressbar.
- clear(nolock=False)
Clear current bar display.
- refresh(nolock=False, lock_args=None)
Force refresh the display of this bar.
- unpause()
Restart tqdm timer from last print time.
- reset(total=None)
Resets to 0 iterations for repeated use.
Consider combining with leave=True.
- set_description(desc=None, refresh=True)
Set/modify description of the progress bar.
- set_description_str(desc=None, refresh=True)
Set/modify description without ': ' appended.
- set_postfix(ordered_dict=None, refresh=True, **kwargs)
Set/modify postfix (additional stats) with automatic formatting based on datatype.
- set_postfix_str(s='', refresh=True)
Postfix without dictionary expansion, similar to prefix handling.
- moveto(n)
- display(msg=None, pos=None)
Use self.sp to display msg in the specified pos.
Consider overloading this function when inheriting to use e.g.: self.some_frontend(**self.format_dict) instead of self.sp.
- Parameters
msg (str, optional. What to display (default: repr(self)).) --
pos (int, optional. Position to moveto) -- (default: abs(self.pos)).
- classmethod wrapattr(stream, method, total=None, bytes=True, **tqdm_kwargs)
stream : file-like object. method : str, "read" or "write". The result of read() and
the first argument of write() should have a len().
>>> with tqdm.wrapattr(file_obj, "read", total=file_obj.size) as fobj: ... while True: ... chunk = fobj.read(chunk_size) ... if not chunk: ... break