[英]Pandas DataFrame (TypeError: Empty 'DataFrame': no numeric data to plot)
I'm trying to learn how to use pandas and im trying to display a plot showing the total births by sex & year. 我正在尝试学习如何使用熊猫,并试图显示一个按性别和年份显示总出生人数的图表。
[1] [ http://i.stack.imgur.com/R7Vz7.png] (Cant figure out why there's another column called sex [1] [ http://i.stack.imgur.com/R7Vz7.png] (无法弄清楚为什么还有另一列叫做性
but this image above the data im trying to plot 但是这张图片正试图绘制数据上方
and keep getting TypeError: Empty 'DataFrame': no numeric data to plot) 并继续获取TypeError:空'DataFrame':没有要绘制的数字数据)
This is what my code looks like 这就是我的代码
[2] http://i.stack.imgur.com/FbZmM.png [2] http://i.stack.imgur.com/FbZmM.png
This is happening because during the pivot the dataFrame becomes multi-indexed. 发生这种情况是因为在数据透视期间,dataFrame变为多索引。 There are no columns with values to plot against eachother.
没有可相互绘制值的列。 You can use
df.reset_index()
to set the multiple indexes as columns, and then plot their values. 您可以使用
df.reset_index()
将多个索引设置为列,然后绘制其值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.