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]:
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')
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')
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')
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')
Out[4]:
In [ ]: