Untitled

 avatar
unknown
plain_text
2 years ago
289 B
3
Indexable
district_counts = data.groupby(['district', 'category'])['name'].count().reset_index(name='count_all')
district_counts['total_count_all'] = district_counts.groupby('district')['count_all'].transform('sum')
district_counts = district_counts.sort_values('total_count_all', ascending=False)
Editor is loading...