Making a bar chart

Introduction to Data Science in Python

Hillary Green-Lerman

Lead Data Scientist, Looker

Comparing pet crimes

precinct pets_abducted
Farmburg 10
Cityville 15
Suburbia 9
plt.bar(df.precinct,
        df.pets_abducted)

plt.ylabel('Pet Abductions')
plt.show()

Introduction to Data Science in Python

Horizontal bar charts

plt.barh(df.precinct,
        df.pets_abducted)

plt.ylabel('Pet Abductions')
plt.show()

Introduction to Data Science in Python

Adding error bars

plt.bar(df.precinct, df.pet_abductions,
        yerr=df.error)

plt.ylabel('Pet Abductions')
plt.show()

Introduction to Data Science in Python

Stacked bar charts

Introduction to Data Science in Python

Stacked bar charts

Introduction to Data Science in Python

Stacked bar charts

Introduction to Data Science in Python

Stacked bar charts

plt.bar(df.precinct, df.dog,
        label='Dog')

plt.bar(df.precinct, df.cat,
        bottom=df.dog,
        label='Cat')

plt.legend()
plt.show()

Introduction to Data Science in Python

Let's practice!

Introduction to Data Science in Python

Preparing Video For Download...