Class 3 in-class exercise solution

Contents

Class 3 in-class exercise solution#

Step 0#

import pandas as pd

requests_by_cd = pd.read_csv(
    "https://storage.googleapis.com/python-public-policy2/data/311_community_districts.csv.zip"
)
requests_by_cd.head()
boro_cd Borough CD Name 2010 Population num_311_requests requests_per_capita
0 112 Manhattan Washington Heights, Inwood 190020 14110 0.074255
1 405 Queens Ridgewood, Glendale, Maspeth 169190 12487 0.073805
2 412 Queens Jamaica, St. Albans, Hollis 225919 12228 0.054126
3 301 Brooklyn Williamsburg, Greenpoint 173083 11863 0.068539
4 303 Brooklyn Bedford Stuyvesant 152985 11615 0.075922

Step 1#

import plotly.express as px

fig = px.histogram(
    requests_by_cd,
    x="requests_per_capita",
    title="Number of Community Districts with different volumes of requests per capita",
)
fig.show()