Class 3 in-class exercise solution#
# boilerplate for allowing PDF export
import plotly.io as pio
pio.renderers.default = "notebook+pdf"
Step 0#
import pandas as pd
requests_by_cd = pd.read_csv(
"https://storage.googleapis.com/python-public-policy/data/311_community_districts.csv.zip"
)
requests_by_cd.head()
borocd | Borough | CD Name | 2010 Population | count_of_311_requests | request_per_capita | |
---|---|---|---|---|---|---|
0 | 112 | Manhattan | Washington Heights, Inwood | 190020 | 81403 | 0.428392 |
1 | 405 | Queens | Ridgewood, Glendale, Maspeth | 169190 | 71506 | 0.422637 |
2 | 412 | Queens | Jamaica, St. Albans, Hollis | 225919 | 70362 | 0.311448 |
3 | 301 | Brooklyn | Williamsburg, Greenpoint | 173083 | 68104 | 0.393476 |
4 | 303 | Brooklyn | Bedford Stuyvesant | 152985 | 66360 | 0.433768 |
Step 1#
import plotly.express as px
fig = px.histogram(
requests_by_cd,
x="request_per_capita",
title="Number of Community Districts with different volumes of requests per capita",
)
fig.show()