Seaborn で pandas を使う

Seaborn を使ったデータ可視化入門

Content Team

DataCamp

pandasとは?

  • データ分析用のPythonライブラリ
  • csv、txtなど、さまざまな形式のファイルからデータセットを簡単に読み込める
  • データセットはDataFrameオブジェクトとして扱われる
Seaborn を使ったデータ可視化入門

DataFrameの扱い方

import pandas as pd

df = pd.read_csv("masculinity.csv")
df.head()
    participant_id        age    how_masculine    how_important
0                1    18 - 34         Somewhat         Somewhat
1                2    18 - 34         Somewhat         Somewhat
2                3    18 - 34             Very         Not very
3                4    18 - 34             Very         Not very
4                5    18 - 34             Very             Very
Seaborn を使ったデータ可視化入門

countplot()でDataFrameを使用する

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.read_csv("masculinity.csv")
sns.countplot(x="how_masculine", data=df)
plt.show()

A count plot of the "how_masculine" column

Seaborn を使ったデータ可視化入門

First 10 rows of the masculinity DataFrame

Seaborn を使ったデータ可視化入門

An "untidy" DataFrame

Seaborn を使ったデータ可視化入門

練習しましょう!

Seaborn を使ったデータ可視化入門

Preparing Video For Download...