Help us understand the problem. What is going on with this article?

JupyterLabでtqdmでプログレスバー表示して処理状況(学習状況)の可視化

JupyterLab-Google-Chrome-2018_05_28-14_55_11.gif

背景

JupyterNotebookでtqdmの記事はたくさんあるが、JupyterLabでtqdmは(特に日本語記事は)なかったため、記録として書き残しておく。

やりたいこと

  • JupyterLabで、tqdmを使って処理状況(≒学習状況)の可視化。

  • forのループではなく、pandasのapply(ラムダ関数)にも適用したい。

問題

  • 1, 下記のエラーが出る。
    AttributeError: 'function' object has no attribute 'pandas'

  • 2, Error displaying widgetと出る。 image.png

対策

# script有効化
jupyter nbextension enable --py --sys-prefix widgetsnbextension

# ipyvolumeのインストール
jupyter labextension install ipyvolume

# jupyterlab-managerのインストール(要:バージョン確認!)
jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.0
  • jupyterlab-managerのバージョンは、JupyterLabのバージョンを確認してから、ここで確認する。

  • JupyterLabのバージョンは、JupyterLab起動後、Help -> About JupyterLab Betaで確認できる。

  • コード例1
from tqdm._tqdm_notebook import tqdm_notebook
import numpy as np

# tqdm_notebookで囲うだけ
for a in tqdm_notebook(np.arange(1, 10000000, 1)):
    # ここに処理
    a = a
  • コード例2
# pandasのapplyへ適用
# import
from tqdm._tqdm_notebook import tqdm_notebook

# set description
tqdm_notebook.pandas(desc="Processing:")

# apply
df['hoge'] = df['hoge'].progress_apply(lambda x:  x + 1)
  • 表示される image.png
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away