Customer Service Requests Analysis - Solution
Customer Service Requests Analysis - Solution
D:\SoftwarePrograms\anaconda\lib\site-packages\IPython\core\interactiveshell.py:314
6: DtypeWarning: Columns (48,49) have mixed types.Specify dtype option on import or
set low_memory=False.
has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
In [3]: df.head()
Out[3]:
Created Closed Agency Complaint Incid
Agency Descriptor Location Type
Date Date Name Type
Unique
Key
5 rows × 52 columns
In [4]: df.shape
In [5]: df.columns
In [6]: df.describe()
In [7]: df['Descriptor'].unique()
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Complaint type Breakdown with bar plot to figure out majority of complaint
types and top 10 complaints
In [13]: #Complaint type Breakdown with bar plot to figure out majority of complaint types an
df['Complaint Type'].value_counts().head(10).plot(kind='barh',figsize=(5,5));
7 Traffic 4498
df_perfect=prepareData(df)
(df_perfect['Complaint Type'].value_counts()).head(15).plot(kind='bar',figsize=(10,6
Least Complaints
In [19]: (df_perfect['Complaint Type'].value_counts()).tail(10).plot(kind='bar',figsize=(10,6
In [20]: df['Borough'].value_counts().plot(kind='pie',autopct='%1.1f%%',explode=(0.15,0,0,0,0
Out[20]: <AxesSubplot:ylabel='Borough'>
In [ ]:
Out[23]: Request_Closing_Time
Request_Closing_Time
Vending 3.791013
69 rows × 1 columns
Hypothesis testing
Whether the average response time across complaint
types is similar or not (overall)
Out[26]: 3.929396621862499
In [27]: df_perfect.shape
sample_data = df_perfect.sample(n=2000)
Hnull = "Response time accross the complain type is not similar"
Halt = "Response time accross the complain type is similar"
Reject the null hypothesis i.e Response time accross the complain type is similar
In [32]: datatable.head()
Complaint Type
Animal Abuse 0 0 62 0 93 0 0
Animal in a Park 0 0 0 0 0 0 1
Bike/Roller/Skate
0 0 0 0 0 0 0
Chronic
Blocked
0 0 0 0 0 0 0
Driveway
Derelict Vehicle 0 0 0 13 0 0 0
In [35]: if pvalue<alpha:
print("Reject the null Hypothesis i.e ",end=' ')
print(Halt)
else:
print("Accept the null Hypothesis i.e",end=' ')
print(Hnull)
Reject the null Hypothesis i.e there is relation between the compalin and location
there is no reltation betweent the Complain and Location
In [ ]: