In [ ]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('ggplot')
import dateutil.parser

First, I made a mistake naming the data set! It's 2015 data, not 2014 data. But yes, still use 311-2014.csv. You can rename it.

Importing and preparing your data

Import your data, but only the first 200,000 rows. You'll also want to change the index to be a datetime based on the Created Date column - you'll want to check if it's already a datetime, and parse it if not.


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:

What was the most popular type of complaint, and how many times was it filed?


In [ ]:

Make a horizontal bar graph of the top 5 most frequent complaint types.


In [ ]:

Which borough has the most complaints per capita? Since it's only 5 boroughs, you can do the math manually.


In [ ]:

According to your selection of data, how many cases were filed in March? How about May?


In [ ]:


In [ ]:

I'd like to see all of the 311 complaints called in on April 1st.

Surprise! We couldn't do this in class, but it was just a limitation of our data set


In [ ]:

What was the most popular type of complaint on April 1st?

What were the most popular three types of complaint on April 1st


In [ ]:


In [ ]:

What month has the most reports filed? How many? Graph it.


In [ ]:


In [ ]:

What week of the year has the most reports filed? How many? Graph the weekly complaints.


In [ ]:


In [ ]:

Noise complaints are a big deal. Use .str.contains to select noise complaints, and make an chart of when they show up annually. Then make a chart about when they show up every day (cyclic).


In [ ]:


In [ ]:

Which were the top five days of the year for filing complaints? How many on each of those days? Graph it.


In [ ]:


In [ ]:

What hour of the day are the most complaints? Graph a day of complaints.


In [ ]:


In [ ]:

One of the hours has an odd number of complaints. What are the most common complaints at that hour, and what are the most common complaints the hour before and after?


In [ ]:


In [ ]:


In [ ]:

So odd. What's the per-minute breakdown of complaints between 12am and 1am? You don't need to include 1am.


In [ ]:

Looks like midnight is a little bit of an outlier. Why might that be? Take the 5 most common agencies and graph the times they file reports at (all day, not just midnight).


In [ ]:

Graph those same agencies on an annual basis - make it weekly. When do people like to complain? When does the NYPD have an odd number of complaints?


In [ ]:

Maybe the NYPD deals with different issues at different times? Check the most popular complaints in July and August vs the month of May. Also check the most common complaints for the Housing Preservation Bureau (HPD) in winter vs. summer.


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: