LoginSignup
43
52

More than 5 years have passed since last update.

【便利!】pandas-profiling(Python)による簡易データ解析

Last updated at Posted at 2019-02-09

pandas-profilingとは?

pandas-profiling は、pandas の DataFrame のプロファイリング結果をまとめて出力できるライブラリです。
DataFrame の基本的な統計量や相関係数などを一度にまとめて確認でき非常に便利です。

特徴
・ 使いやすい(1行のコードで実行可・パラメータ設定不要)
・ 手っ取り早く多角的にデータを解析してくれる
・ グラフを出力しビジュアル面でも分かりやすい

参照元データ
Github : https://github.com/pandas-profiling/pandas-profiling
Demo : https://nbviewer.jupyter.org/github/JosPolfliet/pandas-profiling/blob/master/examples/meteorites.ipynb

インストール〜実行

データはKaggleのTitanicのTrainデータを使用します
https://www.kaggle.com/c/titanic/data

# 未インストールの場合はpipでインストール
pip install pandas-profiling
# ライブラリをインポート
import pandas as pd
import pandas_profiling
# データファイルを読み込む
df = pd.read_csv('titanic/train.csv')
# 実行
pandas_profiling.ProfileReport(df)

4つのセクションに分かれて分析結果が出力されます。

Screen Shot 2019-02-09 at 11.12.24.png
①Overview
データ全体の情報を表示してくれます。
欠損値の割合やデータ型なども一目で確認できますし、Warningsの部分では各特徴量の注意点(欠損値が多い、0の割合が多い...等)を教えてくれます。

Screen Shot 2019-02-09 at 11.12.41.png
②Variables
各変数に対して簡単な分析結果が得られます。
データ型に応じてグラフの形態が変わり非常に親切です。
欠損データが目立つと赤で強調されます。

Screen Shot 2019-02-09 at 11.14.13.png
③Correlations
ヒートマップで相関関係を可視化します。
相関の強い変数のペアを視覚的に理解できます。
ピアソンとスピアマンの両方の結果を出力してくれます。

Screen Shot 2019-02-09 at 11.17.45.png
④Sample
df.head()と同じ出力を表示。
基本的にデータを扱う際、必ず.head()は使うので手間を省けます。

使ってみた感想

とにかくスピーディなのがいいですね。
これだけでは不十分ですが、ざっくりデータを分析する際に非常に便利です。
EDA (探索的データ解析) の第一歩として非常に有用だと感じました。
Kaggleなどのコンペでも1発目に使っていきたいです。

43
52
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
43
52