Matplotlib图未显示 [英] Matplotlib plot is a no-show
本文介绍了Matplotlib图未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行这段代码时
import pandas as pd
import numpy as np
def add_prop(group):
births = group.births.astype(float)
group['prop'] = births/births.sum()
return group
pieces = []
columns = ['name', 'sex', 'births']
for year in range(1880, 2012):
path = 'yob%d.txt' % year
frame = pd.read_csv(path, names = columns)
frame['year'] = year
pieces.append(frame)
names = pd.concat(pieces, ignore_index = True)
total_births = names.pivot_table('births', rows = 'year', cols = 'sex', aggfunc = sum)
total_births.plot(title = 'Total Births by sex and year')
我没有情节.这摘自Wes McKinney的书,该书使用Python进行数据分析. 谁能指出我正确的方向?
I get no plot. This is from Wes McKinney's book on using Python for data analysis. Can anyone point me in the right direction?
推荐答案
输入
import matplotlib.pyplot as plt
位于顶部,
plt.show()
最后.
这篇关于Matplotlib图未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文