Visualisaties automatiseren vanuit data

Introductie tot datavisualisatie met Matplotlib

Ariel Rokem

Data Scientist

Waarom automatiseren?

  • Snelheid en gemak
  • Flexibiliteit
  • Robuustheid
  • Herhaalbaarheid
Introductie tot datavisualisatie met Matplotlib

Hoeveel verschillende datatypes?

summer_2016_medals["Sport"]
ID
62            Rowing
65         Taekwondo
73          Handball
             ...
134759      Handball
135132    Volleyball
135205        Boxing
Name: Sport, Length: 976, dtype: object
Introductie tot datavisualisatie met Matplotlib

Unieke waarden van een kolom ophalen

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

print(sports)
['Rowing' 'Taekwondo' 'Handball' 'Wrestling' 
'Gymnastics' 'Swimming' 'Basketball' 'Boxing' 
'Volleyball' 'Athletics']
Introductie tot datavisualisatie met Matplotlib

Staafdiagram: lengtes per sport

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()
Introductie tot datavisualisatie met Matplotlib

Figuur automatisch uit de data afgeleid

Introductie tot datavisualisatie met Matplotlib

Laten we oefenen!

Introductie tot datavisualisatie met Matplotlib

Preparing Video For Download...