Pandas value_counts用法

import matplotlib.pyplot as plt

import seaborn as sns

show_sz = show_data[show_data.show_city == '深圳'] # show_data为dataFrame

city_counts = show_data['show_city'].value_counts() #city_counts为Series

city_counts[:10] #输出如下



plt.tick_params(labelsize=7) #设置刻度值的字体

sub_set = city_counts[:20]  # 获取city_counts前20个数据

sns.barplot(y = sub_set.index,x = sub_set.values)  # 绘制柱状图如下


你可能感兴趣的:(Pandas value_counts用法)