Untitled

 avatar
unknown
plain_text
2 years ago
785 B
3
Indexable
# Мержим датафреймы для доступа к общему кол-ву заведений по округам
district_counts_low_2 = district_counts_low.merge(
            district_counts[['district', 'category', 'count_all', 'total_count_all']], on=['district', 'category'], how='left'
            )
district_counts_low_2['share_category'] = (district_counts_low_2['count_low'] / district_counts_low_2['count_all'])\
                                        .apply(lambda x: '{:.2%}'.format(x))
district_counts_low_2['share_all'] = (district_counts_low_2['total_count_low'] / district_counts_low_2['total_count_all'])\
                                        .apply(lambda x: '{:.2%}'.format(x))

district_counts_low_2.sort_values('share_all', ascending=False)
Editor is loading...