データから図を自動生成する

Matplotlibで学ぶデータ可視化入門

Ariel Rokem

Data Scientist

なぜ自動化するのか

  • 迅速で手軽
  • 柔軟
  • 頑健
  • 再現可能
Matplotlibで学ぶデータ可視化入門

異なるデータの種類はいくつ?

summer_2016_medals["Sport"]
ID
62            Rowing
65         Taekwondo
73          Handball
             ...
134759      Handball
135132    Volleyball
135205        Boxing
Name: Sport, Length: 976, dtype: object
Matplotlibで学ぶデータ可視化入門

列のユニーク値を取得する

sports = summer_2016_medals["Sport"].unique()

print(sports)
['Rowing' 'Taekwondo' 'Handball' 'Wrestling' 
'Gymnastics' 'Swimming' 'Basketball' 'Boxing' 
'Volleyball' 'Athletics']
Matplotlibで学ぶデータ可視化入門

全競技の身長の棒グラフ

fig, ax = plt.subplots()

for sport in sports:
  sport_df = summer_2016_medals[summer_2016_medals["Sport"] == sport]

ax.bar(sport, sport_df["Height"].mean(), yerr=sport_df["Height"].std())
ax.set_ylabel("Height (cm)") ax.set_xticklabels(sports, rotation=90) plt.show()
Matplotlibで学ぶデータ可視化入門

データから自動生成された図

Matplotlibで学ぶデータ可視化入門

可視化の自動化を練習しましょう!

Matplotlibで学ぶデータ可視化入門

Preparing Video For Download...