plot时为何不显示图形?

panzhixiong_cn 2017-10-18 06:01:10
我使用的是Canopy集成开发环境,如下代码都正常运行,但就是没有图出来。请教各位大神了?
import pandas as pd

names1980 = pd.read_csv('D:/data/names/yob1880.txt', names=['name', 'sex', 'births'])

years = range(1880, 2011)

pieces = []
columns = ['name', 'sex', 'births']

for year in years:
path = 'D:/data/names/yob%d.txt' % year
frame = pd.read_csv(path, names=columns)

frame['year'] = year
pieces.append(frame)

#将所有数据整合到单个DataFrame中
names = pd.concat(pieces, ignore_index=True)

total_births = names.pivot_table('births', index='year', columns='sex', aggfunc=sum)


total_births.plot(title='Total births by sex and year')[/code]
...全文
741 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
secsilm 2017-10-21
  • 打赏
  • 举报
回复
需要用 plt.show() 来显示,前面导入 matplotlib 模块:import matplotlib.pyplot as plt

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧