gpt4 book ai didi

python-3.x - 为什么我的 python 不适用于 seaborn

转载 作者:行者123 更新时间:2023-12-01 12:20:06 25 4
gpt4 key购买 nike

import pandas as pd
import numpy as np
import sklearn
from scipy import stats
import matplotlib.pyplot as plt
import os
import seaborn as sns


sns.set(); np.random.seed(0)
x = np.random.randn(100)

sns.distplot(x)

我只是从文档中复制了示例,但是我得到了这样的错误,我试图在 shell 中更改环境以运行它。但也失败了。

Traceback (most recent call last):
File "/Users/Betterwittyman/Desktop/job_25/别人的/pdf_model2.py", line 13, in <module>
sns.distplot(x)

TypeError: slice indices must be integers or None or have an __index__ method

最佳答案

你能告诉我你使用的 numpy 和 statsmodel 版本吗?

您可以尝试以下方法:

1)使用

更新statsmodel包
pip install -U statsmodels

2) 你能试试运行下面的命令,如果成功了就告诉我?

sns.distplot(x, bins=50, kde=False)
plt.show()

P.S:您的代码对我有用:numpy:1.11.3,scipy:0.18.1,statsmodels:0.6.1

关于python-3.x - 为什么我的 python 不适用于 seaborn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45077834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com