Tqdm: Adding custom information on pandas progress_apply

Created on 31 Aug 2020  Â·  4Comments  Â·  Source: tqdm/tqdm

  • [ ] I have marked all applicable categories:

    • [ ] exception-raising bug

    • [ ] visual output bug

    • [ ] documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand [StackOverflow#tqdm] is more appropriate)

    • [x] new feature request

  • [x] I have visited the [source website], and in particular
    read the [known issues]
  • [x] I have searched through the [issue tracker] for duplicates
  • [ ] I have mentioned version numbers, operating system and
    environment, where applicable:
    ```python
    import tqdm, sys
    print(tqdm.__version__, sys.version, sys.platform)

4.42.1 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0] linux
`` Can't add a custom information message such asset_postfixfor example when dealing with pandas dataframeprogress_apply` function.

questiodocs ‽ submodule ⊂

Most helpful comment

That's not exactly currently supported, and it wouldn't be easy to add without breaking backward compatibility.

The easiest approach would be explicitly defining a bar_format, e.g:

tqdm.pandas(
    bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}, iter={n}]")
df.progress_apply(...)

All 4 comments

#from tqdm.auto import tqdm
from tqdm import tqdm
import pandas as pd

df = pd.DataFrame(...)
tqdm.pandas(desc="customised", postfix={"hello": -1})
df.progress_apply(...)

tqdm.pandas(desc="remove postfix", postfix=None)
df.progress_apply(...)

I agree this is clunky but (kw)arguments to df.progress_apply are all passed to df.apply

#from tqdm.auto import tqdm
from tqdm import tqdm
import pandas as pd

df = pd.DataFrame(...)
tqdm.pandas(desc="customised", postfix={"hello": -1})
df.progress_apply(...)

tqdm.pandas(desc="remove postfix", postfix=None)
df.progress_apply(...)

I agree this is clunky but (kw)arguments to df.progress_apply are all passed to df.apply

Can I change the postfix string based on the iteration dynamically instead of having some fixed postfix ?

That's not exactly currently supported, and it wouldn't be easy to add without breaking backward compatibility.

The easiest approach would be explicitly defining a bar_format, e.g:

tqdm.pandas(
    bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}, iter={n}]")
df.progress_apply(...)

Cool, thank you so much for your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

freeboson picture freeboson  Â·  4Comments

mrclary picture mrclary  Â·  5Comments

CrazyPython picture CrazyPython  Â·  5Comments

Haffi112 picture Haffi112  Â·  5Comments

schwobr picture schwobr  Â·  5Comments