【Pandas数据可视化:Part 1】单变量绘图

常见四种用来绘制单变量分布的图形:柱状图,线形图,区域图,直方图

import pandas as pd
reviews = pd.read_csv("winemag-data_first150k.csv",index_col=0)
reviews.head(3)

reviews.dtypes  
#查看一下数据类型

print(reviews.size)   # 行 * 列 的整形结果
print(reviews.shape)  # 行 , 列 的数组

reviews['province'].value_counts().head(10)

#字段Province统计,Province字段值出现最频繁的前十个
reviews['province'].value_counts().head(10).plot.bar()

#计算百分比
reviews['province'].value_counts().head(10)/len(reviews)

#查看 points字段的排序结果
reviews['points'].value_counts().sort_index()

#线形图
reviews['points'].value_counts().sort_index().plot.line()

#区域图
reviews['points'].value_counts().sort_index().plot.area()

猜你喜欢

转载自blog.csdn.net/u013617144/article/details/81240578
今日推荐