The data come from NYC Open Data – 311 Service Requests. The downloaded period covers 20 August through 1 September 2026 (the end date is exclusive).
For this lab, we are not interested in all 311 complaints. We will keep only complaints handled by the New York City Police Department and related to noise.
Columns to look at
Pay particular attention to:
created_date — when the complaint was created. Use this column to organize complaints into time intervals.
agency_name — the full name of the responsible agency. We want New York City Police Department.
complaint_type — the main complaint category. We want complaint types beginning with Noise.
descriptor — a more detailed description of the complaint, such as Loud Music/Party.
location_type — where the complaint was reported.
We will mainly use created_date, agency_name, and complaint_type in this lab.
import pandas as pdimport numpy as npimport plotly.express as pximport plotly.graph_objects as gofrom scipy import statsfrom urllib.parse import quotetarget_date ="2026-08-20"end_date ="2026-09-01"dataset_id ="erm2-nwe9"where_clause = (f"created_date >= '{target_date}T00:00:00' "f"AND created_date < '{end_date}T00:00:00'")url = (f"https://data.cityofnewyork.us/resource/{dataset_id}.csv"f"?$where={quote(where_clause)}&$limit=50000")data = pd.read_csv(url)print(f"Downloaded {len(data):,} records.")print(data.shape)data.head()
Downloaded 50,000 records.
(50000, 44)
unique_key
created_date
closed_date
agency
agency_name
complaint_type
descriptor
descriptor_2
location_type
incident_zip
...
vehicle_type
taxi_company_borough
taxi_pick_up_location
bridge_highway_name
bridge_highway_direction
road_ramp
bridge_highway_segment
latitude
longitude
location
0
70248760
2026-08-31T01:59:39.000
NaN
DOT
Department of Transportation
Street Condition
Pothole
NaN
NaN
11412.0
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
40.694215
-73.753087
POINT (-73.753087331085 40.694214514285)
1
70243572
2026-08-31T01:50:52.000
NaN
NYPD
New York City Police Department
Noise - Street/Sidewalk
Loud Music/Party
NaN
Street/Sidewalk
10472.0
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
40.827242
-73.874057
POINT (-73.874056693475 40.827242433541)
2
70239573
2026-08-31T01:50:48.000
NaN
DOHMH
Department of Health and Mental Hygiene
Smoking or Vaping
Allowed in Smoke Free Area
Cannabis Smoking or Vaping
Residential Building
11221.0
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
40.693773
-73.915534
POINT (-73.91553395065 40.693773172836)
3
70249101
2026-08-31T01:50:26.000
NaN
NYPD
New York City Police Department
Noise - Commercial
Loud Music/Party
NaN
Club/Bar/Restaurant
11226.0
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
40.654245
-73.952867
POINT (-73.952867166126 40.654245046963)
4
70248458
2026-08-31T01:50:21.000
NaN
NYPD
New York City Police Department
Noise - Street/Sidewalk
Loud Music/Party
NaN
Street/Sidewalk
11354.0
...
NaN
NaN
NaN
NaN
NaN
NaN
NaN
40.766446
-73.829089
POINT (-73.829089290124 40.766446350276)
5 rows × 44 columns
data.query("agency_name == 'New York City Police Department' and complaint_type.str.startswith('Noise')").shape