Pandas Dataframe不允许按索引进行选择

2024-05-18 20:14:43 发布

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

我不知道为什么会这样:

enter image description here

作品:

miez['month'].head()
5120    201904
5121    201904
5122    201904
5123    201904
5124    201904
Name: month, dtype: int64

不起作用:

^{pr2}$

我不知道我错过了什么。熊猫0.23版。在

解决方案:正如在注释部分中建议的那样,索引字段名中有空格,这就是为什么它不起作用。在

miez.columns
Index(['month', ' file_name', ' file_size'], dtype='object')

Tags: columnsnameindex解决方案head作品建议file

热门问题