Easy-to-see tqdm on the Jupyter notebook

Introduction

I installed tqdm to see progress bars in the Jupyter notebook.

However when I use tqdm normally for nested “for statements”, full of progress bars are displayed….

So, this post is about a way to make tqdm on the Jupyter notebook easier to see.

install tqdm

I have installed tqdm with pip in the terminal (because I manage packages with pip).

pip install tqdm

full of progress bars…

from tqdm import tqdm

then,

Using tqdm normally for nested “for statements”, it seems to be output every time the situation is updated, so it is hard to see because it comes out in a row….Oh my….

Use tqdm.notebook to avoid clutter

Just use tqdm.notebook instead of normal tqdm.

from tqdm.notebook import tqdm

It becomes much easier to see and look better.

Adding “leave = False”, it will be more simple-looking.

As a side note, in order to use tqdm with pandas data, just type;

tqdm.pandas() 

Other notes

It seems to use tqdm.notebook now

It seems that tqdm_notebook have been used until a while ago, so even on the sites I referred to,

from tqdm import tqdm_notebook as tqdm

But as use of tqdm_notebook, the following warning will appear.

TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0 Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`

Although we can still run tqdm_notebook,
it has updated(replaced?) to tqdm.notebook at some point, and tqdm_notebook will be removed in ver.5.0.0….

When HBox…. appear and the progress bar does not appear

On running with tqdm,

HBox(children=(FloatProgress(value=0.0, description='1st loop', max=4.0, style=ProgressStyle(description_width…

encounter something like this and the progress bar does not appear, it seems that the settings in ipywidgets are not enough.

To solve this, install ipywidgets with

 pip install ipywidgets 

then type

jupyter nbextension enable --py widgetsnbextension

and launch the Jupyter notebook.

In my case, I was told that there was no wheel, so I added wheel with pip.

pip install wheel

Now it works fine.

I’m glad it’s a little more comfortable.

Environment:

Python; 3.7.2
Jupyter ; 1.0.0
macOS; Catalina version 10.15.4

The sites that I mainly referred to. Thank you very much.
https://towardsdatascience.com/progress-bars-in-python-and-pandas-f81954d33bae
https://ipywidgets.readthedocs.io/en/latest/user_install.html


ちょっと広告です
https://business.xserver.ne.jp/

https://www.xdomain.ne.jp/

★LOLIPOP★

.tokyo

MuuMuu Domain!