0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

データの全体像を見るときはPandas Profilingが便利

Posted at

最近Pandas Profilingという便利なライブラリがあることを知りました。
備忘録も兼ねて使い方をまとめておきたいと思います。

インストール方法

pip, condaいずれでもインストール可能です。

pipの場合

condaの場合

実行方法

試しにsklearnのBoston Housingデータを使ってみました。

# 使用するライブラリ
import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport
from sklearn.datasets import load_boston

まずはBoston Housingデータをデータフレーム化します。

boston = load_boston()
df = pd.DataFrame(boston.data, columns=boston.feature_names)

このデータフレームをProfileReportに入れることで、データ全体の相関など様々な統計量を表示してくれます。

ProfileReport(df)

jupyter notebook上に表示された結果の一部。変数の個数だけでなく、dfの行数や欠損値、重複行の有無なども教えてくれます。

スクリーンショット 2021-10-05 11.05.54.png

出力結果のgif。変数間の相関なども可視化されています。

output_5f.gif

最後に、得られた結果はhtmlやjsonとして保存ができます。

profile = ProfileReport(df)
profile.to_file('boston.html')

 参考

Pandas Profiling

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?