Reputation: 575
I want to group by two columns. day of the week and another second column. but I don't know How should I do this. It is my query for one column:
grouped = (df.groupby(df['time'].dt.weekday_name)['id'].count().rename('count'))
Where should I add the second column? for example "type" column in my dataframe.
Upvotes: 1
Views: 399
Reputation: 36594
df.groupby()
takes a list, like this:
df.groupby([df['time'].dt.weekday_name, df['type']])
Upvotes: 1