Python question: the time is from 2016-01-01 ~ 2018-12-31 such as the columns "Month", "Day", "Year"
I need to count how many rows data for each day, and each Borough, such as the column "Borough". The Borough includes: QUEENS, BROOKLYN, BRONX, MANHATTAN, STATEN ISLAND, all together is 5 different Boroughs.
Many Thanks!
my sample data set
code and output select appropriate one as you need
Code
import pandas as pd #reading my sample dataset df=pd.read_csv("Records.csv") #simple group by with count complaintCount=df.groupby(['Month','Day','Year','Borough'])['Complaint Type'].count() print(complaintCount) #Group by with changing count column name to 'Complaint Count' complaintCount=df.groupby(['Month','Day','Year','Borough'])['Complaint Type'].count().reset_index() complaintCount.rename(columns={'Complaint Type':'Complaint Count'},inplace='True') print(complaintCount)
Python question: the time is from 2016-01-01 ~ 2018-12-31 such as the columns "Month", "Day", "Year"...
price time month day year 149.3999939 1 01 02 13 146.5 2 01 03 13 147.3499908 3 01 04 13 150.3999939 4 01 07 13 148.1499939 5 01 08 13 147.8999939 6 01 09 13 149.6499939 7 01 10 13 153.3499908 8 01 11 13 153.3000031 9 01 14 13 152.5 10 01 15 13 153 11 01 16 13 155.5 12 01 17 13 156.3000031 13 01 18 13 148.5999908 14 01 22 13 150.3999939 15 01 23 13...