alphatwirl / atpbar

Progress bars for threading and multiprocessing tasks on terminal and Jupyter Notebook
https://alphatwirl.github.io/atpbar/
MIT License
92 stars 10 forks source link

exporting class Atpbar in __init__.py #29

Open Nicolas-Reyland opened 1 year ago

Nicolas-Reyland commented 1 year ago

Exporting the Atpbar class, so that progress bars can be created for iterable objects for which one knows then length, but for which the __len__() method is not implemented.

Nicolas-Reyland commented 1 year ago

If you wonder about my use case, here is an example: pandas dataframes have many iterators. For example, if you want to iterate over a dataframe using the itertuples method, you find yourself with a valid iterator for which you know the length (df.shape[0]), but which can't be thrown to the atpbar function. What I ended up doing was this: Atpbar = type(atpbar([1, 2, 3])). And then later: for row_a in Atpbar(a.itertuples(), len_=a.shape[0], ...).

I don't find this very elegant. I am open to suggestions.