首页 > 解决方案 > Python无法识别用于绘图的数据框的数据类型

问题描述

df在 python 中有以下数据框:

Color     Blue     Red    Green   Yellow  Orange

 Zone
-------------------------------------------------
   1A      3.5     3.6      2.9      3.2     3.9
   2B      3.2     4.1      2.6      2.3     3.4
   3C      2.9     3.9      3.1      2.7     3.0

以前我可以通过简单地运行来生成一个情节:

df.plot(kind='bar', color=['b', 'c', 'g', 'm', 'r'], sharey=True, legend=True, rot=True, zorder=1.6)

但是,现在运行此行会产生以下错误消息:

TypeError: Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type

为什么会发生此错误,我该如何解决?

标签: pythonnumpyplot

解决方案


推荐阅读