I have the dataset of sales of cars in various cities in which I want to divide the dataset into city-wise quarter sales I tried the code but it didn't work.
qu=df.groupby([(df.City),(df.index.year),(df.quarter)]).agg(['sum', 'count'])
I have the dataset of sales of cars in various cities in which I want to divide the dataset into city-wise quarter sales I tried the code but it didn't work.
qu=df.groupby([(df.City),(df.index.year),(df.quarter)]).agg(['sum', 'count'])
Try something like
df['year'] = df.index.dt.year # Based on your index name
df.groupby(by=['City','year','quarter']).agg(['sum','count'])