DDsumDOB = T_DOBCR.groupby(["COMPLAINT CATEGORY DESCRIPTION","Y_DEntered",'borough'],as_index=False).sum('counter').sort_values(["counter"],ascending = False)
DDsumDOB2 = T_DOBCR.groupby(["COMPLAINT CATEGORY DESCRIPTION",'borough'],as_index=False).sum('counter').sort_values(["counter"],ascending = False)
DDsumDOB = DDsumDOB.drop('ReactionTime',axis=1)
DDsumDOB2 = DDsumDOB2.drop('ReactionTime',axis=1)
DDsumDOB = DDsumDOB.merge(DOBCatalog,on = ['COMPLAINT CATEGORY DESCRIPTION'], how='left')
DDsumDOB2 = DDsumDOB2.merge(DOBCatalog,on = ['COMPLAINT CATEGORY DESCRIPTION'], how='left')
Bronx = DDsumDOB.loc[DDsumDOB.borough=='Bronx']
Brooklyn = DDsumDOB.loc[DDsumDOB.borough=='Brooklyn']
Manhattan = DDsumDOB.loc[DDsumDOB.borough=='Manhattan']
Queen = DDsumDOB.loc[DDsumDOB.borough=='Queen']
StatenIsland = DDsumDOB.loc[DDsumDOB.borough=='Staten Island']
Bronx2020 = Bronx.loc[Bronx.Y_DEntered=='2020']
Bronx2020 = Bronx2020.sort_values(["Complaint Category"],ascending = False)
Bronx2021 = DDsumDOB2.loc[DDsumDOB2.borough=='Bronx']
Bronx2021 = Bronx2021.sort_values(["Complaint Category"],ascending = False)
Brooklyn2020 = Brooklyn.loc[Brooklyn.Y_DEntered=='2020']
Brooklyn2021 = DDsumDOB2.loc[DDsumDOB2.borough=='Brooklyn']
Brooklyn2020 = Brooklyn2020.sort_values(["Complaint Category"],ascending = False)
Brooklyn2021 = Brooklyn2021.sort_values(["Complaint Category"],ascending = False)
Manhattan2020 = Manhattan.loc[Manhattan.Y_DEntered=='2020']
Manhattan2021 = DDsumDOB2.loc[DDsumDOB2.borough=='Manhattan']
Manhattan2020 = Manhattan2020.sort_values(["Complaint Category"],ascending = False)
Manhattan2021 = Manhattan2021.sort_values(["Complaint Category"],ascending = False)
Queen2020 = Queen.loc[Queen.Y_DEntered=='2020']
Queen2021 = DDsumDOB2.loc[DDsumDOB2.borough=='Queen']
Queen2020 = Queen2020.sort_values(["Complaint Category"],ascending = False)
Queen2021 = Queen2021.sort_values(["Complaint Category"],ascending = False)
StatenIsland2020 = StatenIsland.loc[StatenIsland.Y_DEntered=='2020']
StatenIsland2021 = DDsumDOB2.loc[DDsumDOB2.borough=='StatenIsland']
Queen2020 = Queen2020.sort_values(["Complaint Category"],ascending = False)
Queen2021 = Queen2021.sort_values(["Complaint Category"],ascending = False)
# Plot
fig, ax = plt.subplots(figsize=(50, 70))
plt.subplot(141)
plt.scatter( 'counter','Complaint Category', data=Bronx2020, s='counter',marker='o', alpha=0.6)
plt.scatter( 'counter','Complaint Category', data=Bronx2021, s='counter',marker='o', alpha=0.8)
plt.title("Bronx",fontsize=60)
plt.xlabel("Occurrence",fontsize=40)
plt.ylabel("Complaint Category",fontsize=40)
plt.grid(color='lightgrey', linestyle='dashed')
plt.legend(('2020', 'Since 2020'),
loc='upper right', shadow=True,fontsize=40)
plt.xlim(-1, 4000)
plt.subplot(142)
plt.scatter( 'counter','Complaint Category', data=Brooklyn2020, s=300,marker='o', alpha=0.4)
plt.scatter( 'counter','Complaint Category',data=Brooklyn2021, s=500,marker='o', alpha=0.6)
plt.title("Brooklyn",fontsize=60)
plt.xlabel("Occurrence",fontsize=40)
plt.ylabel("Complaint Category",fontsize=40)
plt.grid(color='lightgrey', linestyle='dashed')
plt.legend(('2020', 'Since 2020'),
loc='upper right', shadow=True,fontsize=40)
plt.xlim(-1, 4000)
plt.subplot(143)
plt.scatter( 'counter','Complaint Category', data=Manhattan2020,s=300, marker='o', alpha=0.4)
plt.scatter('counter','Complaint Category', data=Manhattan2021, s=500,marker='o', alpha=0.6)
plt.title("Manhattan",fontsize=60)
plt.xlabel("Occurrence",fontsize=40)
plt.ylabel("Complaint Category",fontsize=40)
plt.grid(color='lightgrey', linestyle='dashed')
plt.legend(('2020', 'Since 2020'),
loc='upper right', shadow=True,fontsize=40)
plt.xlim(-1, 4000)
plt.subplot(144)
plt.scatter( 'counter','Complaint Category',data=Queen2020, s=300,marker='o', alpha=0.4)
plt.scatter('counter','Complaint Category', data=Queen2021, s=500,marker='o', alpha=0.6)
plt.title("Queen",fontsize=60)
plt.xlabel("Occurrence",fontsize=40)
plt.ylabel("Complaint Category",fontsize=40)
plt.grid(color='lightgrey', linestyle='dashed')
plt.legend(('2020', 'Since 2020'),
loc='upper right', shadow=True,fontsize=40)
plt.xlim(-1, 4000)
plt.show()