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'].plot.kde() 22 pyplot.xticks(range(0,max(excel['New_York']),500),rotation=45) 23 pyplot.show()