Numpy-模块没有“arrange”属性

2024-06-17 01:48:09 发布

您现在位置:Python中文网/ 问答频道 /正文

似乎是一个难以置信的基本错误,我试过卸载并重新安装最新版本的Numpy(1.9),但这似乎并不能解决我的问题。尝试使用排列功能时出现以下错误:

Traceback (most recent call last):
  File "names.py", line 37, in <module>
    top1000.index = np.arrange(len(top1000))
AttributeError: 'module' object has no attribute 'arrange'

打印版本确认它确实是1.9。我找不到其他人报告这个具体问题。我也在两台不同的Mac电脑上尝试过,但仍然得到同样的错误。

import numpy as np
import pandas as pd

print np.__version__

grouped = names.groupby(['year', 'sex'])
top1000 = grouped.apply(get_top1000)
top1000.index = np.arrange(len(top1000))

Tags: import功能版本numpyindexlennamesas