作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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/
我是一名优秀的程序员,十分优秀!