AttributeError: 模块“seaborn”没有属性“histplot”

kim*_*kim 25 python jupyter-notebook

我正在尝试使用sns.histplotKaggle 的 Jupyter Notebook 中的 Titanic 数据集进行绘图。

这是我的代码:

sns.histplot(train, x = "Age", hue="Sex")
Run Code Online (Sandbox Code Playgroud)

但它给我这个错误:

 ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-d14c3b5a0670> in <module>
----> 1 sns.histplot(train, x = "Age", hue="Sex")

AttributeError: module 'seaborn' has no attribute 'histplot'
Run Code Online (Sandbox Code Playgroud)

我已确保导入 seaborn(以前使用的图sns.barplot工作正常)。

我在 Mac OS X 10.15.6 和 Seaborn 0.11.0 版上运行。

有人可以指出出了什么问题吗?提前致谢。

Ahs*_*eer 29

我使用以下方法更新了 seaborn 模块:

pip install -U seaborn
Run Code Online (Sandbox Code Playgroud)

它为我解决了这个问题。

  • @TonyBrand 尝试升级到版本 0.11.0。或者你可以尝试 sns.distplot()。以下是您的版本的文档链接:https://seaborn.pydata.org/archive/0.10/tutorial/distributions.html。 (3认同)
  • 我已经更新了我的seaborn,但没有任何改变。它仍然抛出 AttributeError: module 'seaborn' has no attribute 'histplot'。我的seaborn版本是“0.10.1”。 (2认同)
  • 我将seaborn更新为“0.11.1”,但不起作用。`sns.distplot` 有效 (2认同)

小智 7

只是为了扩展 Ahsan Goheer 的答案。尝试使用以下命令更新seaborn:

pip install -U seaborn
Run Code Online (Sandbox Code Playgroud)

然后重新启动笔记本的内核。现在应该可以工作了

  • 这应该是一条评论,而不是一个单独的答案。 (3认同)