我有简单的 Pandas Dataframe:
data.head(5)
> Date Time Open High Low Close Vol OI
> 0 02/02/1993 16:00 44.23 44.38 44.13 44.34 201300 0
> 1 02/03/1993 16:00 44.41 44.84 44.38 44.82 529400 0
> 2 02/04/1993 16:00 44.97 45.10 44.88 45.00 531500 0
> 3 02/05/1993 16:00 44.97 45.06 44.73 44.97 492100 0
> 4 02/08/1993 16:00 44.97 45.13 44.92 44.98 596100 0
我想将“日期”列设置为索引:
data.set_index('Date')
但出现错误“TypeError: 'list' object is not callable”
TypeError Traceback (most recent call last)
<ipython-input-59-a610da45b82c> in <module>()
----> 1 data.set_index('Date')
TypeError: 'list' object is not callable
当前数据中的索引为RangeIndex:
data.index
RangeIndex(start=0, stop=5873, step=1)
有什么提示为什么我无法使用日期列设置索引吗?
谢谢。
最佳答案
使用 set_index 命令时,我遇到了同样的问题“TypeError: 'list' object is not callable”。我通过首先调用“reindex()”方法然后使用 set_index 得到了解决方案。希望对你有帮助。 阿米尔
关于python - 获取类型错误 : 'list' object is not callable when setting index in Pandas Dataframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37481563/