pandas - 将df.index从float64更改为unicode或string
- 论坛
- pandas - 将df.index从float64更改为unicode或string
11 浏览
pandas - 将df.index从float64更改为unicode或string
我想将一个数据框的索引(行)从float64类型更改为字符串或unicode类型。
我原以为以下代码可以实现,但显然不行:
#检查类型 type(df.index) 'pandas.core.index.Float64Index' #将类型更改为unicode if not isinstance(df.index, unicode): df.index = df.index.astype(unicode)
错误信息:
TypeError: 将的数据类型设置为除float64或object之外的任何类型是不支持的