LoginSignup
2
2

More than 5 years have passed since last update.

Jupyter Notebookで綺麗なDataFrameを簡単に表示する(複数可)

Posted at

こちらの記事を参考にさせていただきました。
Jupyter notebookでpandasのDataFrameを綺麗に表示させる方法 - Qiita

この記事の

なお、 jupyte_notebook_config.py に、デフォルトで設定する方法があるらしく、 この記述すら、毎回書かなくて済むらしい。

とある部分です。その具体的なやり方を説明します。

(1) IPython profileを生成する

まず、こちらにもあるようにterminalで
Python Tips:IPython の起動時に特定の処理を走らせたい - Life with Python

ipython profile create

を入力。JupyterNotebookはIPythonを元に作られているので、普通にこちらのコマンドが使えます。

(2) 生成されたファイルに設定を書き込む

次にホームディレクトリ以下に生成された.ipython/profile_defaultの中にあるipython_config.pyファイルを編集します。

その中に、

c.InteractiveShell.ast_node_interactivity = "last_expr" #defaultの設定

と書いてある部分があるのでこちらを

c.InteractiveShell.ast_node_interactivity = "all"

これで変数名を記述するだけで複数のDataFrameを綺麗に表示できます。

(略)
df1
df2

みたいな感じで。

お疲れさまでしたー

2
2
0

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
2
2