Skip to content

Instantly share code, notes, and snippets.

@lvngd lvngd/

Last active Jun 13, 2020
What would you like to do?
import requests
import pandas as pd
Script to fetch 50,000 311 noise complaints from NYC Open Data.
Substitute your own API key.
date = '2020-01-15'
#311 complaints endpoint
endpoint = "$where=created_date<'{}' AND complaint_type like 'Noise%25'&$limit=50000".format(date)
headers={'X-App-Token': NYC_OPEN_DATA_API_KEY}
result = requests.get(endpoint, headers=headers)
noise_complaints = pd.DataFrame(result.json())
#drop irrelevant columns
columns_to_drop = ['address_type', 'agency',
'bbl', 'community_board',
'cross_street_1', 'cross_street_2', 'due_date',
'facility_type', 'landmark',
'intersection_street_1', 'intersection_street_2','location',
'open_data_channel_type', 'park_borough', 'park_facility_name',
'x_coordinate_state_plane', 'y_coordinate_state_plane','city', 'street_name']
#filter for status == 'Closed' then drop status column
noise_complaints = noise_complaints[noise_complaints.status == 'Closed']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.