In [2]:
import plotly
import plotly.tools as tls
import cufflinks as cf
import pandas as pd

In [3]:
my_311 = pd.read_csv('311_no_empty_coordinates.csv')

series = my_311['RequestType'].value_counts()

In [9]:
series.iplot(kind='bar', yTitle='Number of Complaints', title='LA 311 Complaints',
             filename='LA311Requests')


Out[9]:

In [10]:
df1 = my_311.loc[my_311['Created Year'] == 2015]
a = df1.groupby(['Created Year', 'Week Number']).size().unstack()

df2 = my_311.loc[my_311['Created Year'] == 2016]
b = df2.groupby(['Created Year', 'Week Number']).size().unstack()


df3 = my_311.loc[my_311['Created Year'] == 2017]
c = df3.groupby(['Created Year', 'Week Number']).size().unstack()


df4 = my_311.loc[my_311['Created Year'] == 2018]
d = df4.groupby(['Created Year', 'Week Number']).size().unstack()

df = pd.concat([a,b,c,d], axis=0).sort_index()
df


Out[10]:
Week Number 1 2 3 4 5 6 7 8 9 10 ... 44 45 46 47 48 49 50 51 52 53
Created Year
2015 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 11629.0 10915.0 10256.0 10638.0 8275.0 11628.0 11229.0 9930.0 7322.0 7373.0
2016 13079.0 15895.0 15863.0 15817.0 16751.0 16271.0 14840.0 18892.0 17917.0 16938.0 ... 19278.0 16994.0 19365.0 13355.0 19054.0 19190.0 18168.0 16027.0 17598.0 1006.0
2017 18081.0 18873.0 18629.0 20685.0 22172.0 19408.0 17982.0 18753.0 22609.0 21224.0 ... 16030.0 19465.0 12579.0 44.0 6408.0 20465.0 21895.0 19050.0 15612.0 NaN
2018 19607.0 21753.0 23432.0 22871.0 22713.0 23974.0 20732.0 19010.0 21149.0 23774.0 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

4 rows × 53 columns


In [11]:
#Change in Total Requests from a specific week over the course of 3 years
x = int(input('Input Week Number:'))
d = df[x]
d.iplot(kind = 'bar', yTitle='Number of Complaints', title='LA 311 Week Comparisons',
             filename='LA311WeekNumberComparisons')


Input Week Number:12
Out[11]:

In [13]:
#Service Request Types by Specific Weeks
x = int(input('For what week number would you like to see the Request Types? Options: any number between 1 and 53 '))
df = my_311.loc[my_311['Week Number'] == x]
ok = df.groupby(['Week Number', 'RequestType']).size().unstack()
ok.iplot(kind = 'bar', yTitle='Number of Complaints', title='LA 311 Request Types by Week',
             filename='LA311Requests by Week')


For what week number would you like to see the Request Types? Options: any number between 1 and 53 43
Out[13]:

In [28]:
#Concentration of Requests Grouped by Week over the course of a year
x = int(input('For what year would you like to see the Request Types? Options: 2015 to 2018 '))
df = my_311.loc[my_311['Created Year'] == x]
group = df.groupby(['Created Year', 'Week Number']).size().unstack()
group.iplot(kind = 'bar', yTitle='Number of Complaints ', title='LA 311 Week Number Concentration',
             filename='LA311 Requests Week Number Concentrations')


For what year would you like to see the Request Types? Options: 2015 to 2018 2016
Out[28]:

In [31]:
group = my_311.groupby(['Week Number', 'RequestType']).size().unstack()
group.iplot(kind = 'bar', barmode = 'stack', title = '311 All Requests for Weeks', filename= '311 All Requests for Weeks')


Out[31]:

In [4]:
df = my_311.loc[my_311['Created Year'] == 2017]
wow = df['Week Number']
wow.iplot(kind = 'histogram', yTitle='Number of Complaints', title='LA 311 Request Types by Week',
             filename='LA311Requests by Week')


/anaconda3/lib/python3.6/site-packages/plotly/plotly/plotly.py:224: UserWarning:

Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions:
(1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph.
(2) Trying using the image API to return an image instead of a graph URL
(3) Use matplotlib
(4) See if you can create your visualization with fewer data points

If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning.

Out[4]:

In [ ]: