Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
289 B
0
Indexable
Never
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)