绘制直方图

 1 import  pandas
 2 from  matplotlib  import  pyplot
 3 
 4 pandas.options.display.max_columns=10   #最多显示多少列
 5 
 6 excel=pandas.read_excel('revenue.xlsx')
 7 
 8 
 9 #调整列名格式
10 a=list(excel.columns)
11 c=enumerate(a)
12 for d,i in c:
13     if i=='New York':
14         x=i.replace('New York','New_York')
15         a.remove(i)
16         a.insert(d,x)
17 excel.columns=a
18     
19 
20 #画直方图
21 excel['New_York'].hist(bins=100,grid=False)   #bins指分布区间
22 pyplot.xticks(range(0,max(excel['New_York']),500),rotation=45)
23 pyplot.show()

 

posted @ 2020-06-11 16:33  马蹄哒哒  阅读(117)  评论(0编辑  收藏  举报