LoginSignup
58
47

More than 5 years have passed since last update.

Jupyter Notebook でプログレスバーを出す

Posted at

大量のデータの処理をしていると、作業がどのくらい進んだのかわからなくて辛いことがよくあります。そんな時の tqdm!

tqdm 何ができるの?

image.png

イテレーションのコードにすこし加えるだけで、プログレスバーを出せます。

使いたい!

準備

jupyter を実行するサーバーで以下のコマンドを打ってください。
tqdm のインストールと、 js の widget を有効化するぽいことをやります。

pip install tqdm
jupyter nbextension enable --py --sys-prefix widgetsnbextension

コード

for に与えるリスト的な場所に tqdm() をかぶせるだけです。

from tqdm import tqdm_notebook as tqdm

for i in tqdm(range(100000000)):
    i * i - i

image.png

import で tqdm_notebook とかやることで jupyter 上で使えるようになります。
tqdm は元々コマンドラインでプログレスバーを出すやつですが。

58
47
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
58
47