Python 导入打印的问题

Python 导入打印的问题,python,pandas,Python,Pandas,当我进口大熊猫时,一切都很好,而且都在工作。然而,当我试图从熊猫绘图导入一些东西时,我得到了一个错误。这可能是什么原因 以下是输出的外观: >>> import pandas >>> from pandas.plotting import scatter_matrix Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError:

当我进口大熊猫时,一切都很好,而且都在工作。然而,当我试图从熊猫绘图导入一些东西时,我得到了一个错误。这可能是什么原因

以下是输出的外观:

>>> import pandas
>>> from pandas.plotting import scatter_matrix
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named plotting
导入熊猫 >>>从pandas.plotting导入散射矩阵 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 ImportError:没有名为plotting的模块
我使用的pandas版本是:
0.19.2

,不幸的是,该模块的移动似乎有些混乱。
plotting
模块已从
pandas.tools.plotting
移动到
pandas.plotting
。困难很可能源于这样一个事实,即从版本0.19开始,
pandas.plotting
库不存在

当前版本为0.22版。如果收到此错误,最佳做法是将pandas的版本更新为最新版本

如果由于某种原因,您无法做到这一点,那么pandas早期版本的正确代码将是

from pandas.tools.plotting import scatter_matrix
from pandas.plotting import scatter_matrix
当前版本的熊猫的正确代码是

from pandas.tools.plotting import scatter_matrix
from pandas.plotting import scatter_matrix

如果您收到此警告:

main:1:FutureWarning:“pandas.tools.plotting.scatter\u matrix”不推荐使用,请导入“pandas.plotting.scatter\u matrix”


我发现,大多数情况下,当导入散布矩阵出现错误时,这是因为您已经有一段时间没有重新启动jupyter笔记本了。 在我运行代码之前; 从pandas.tools.plotting导入散射矩阵
我确保重新启动jupyter笔记本并运行代码。从那时起,一切正常。

只需在导入散射矩阵时使用此选项:

import pandas.plotting
# insert your scatter_matrix code here and run
# there should be no error messages (unless a new one)
要删除数组文本,可以在代码末尾加“;”

import pandas.plotting
scatter_matrix(df, ...); #put the semi-colon here

在他们的辩护中,确实提到了熊猫。绘图。我重新安装了熊猫软件包并解决了问题!