【发布时间】:2016-05-23 23:01:37
【问题描述】:
我想将数据帧的索引(行)从 float64 更改为字符串或 unicode。
我认为这可行,但显然不行:
#check type
type(df.index)
'pandas.core.index.Float64Index'
#change type to unicode
if not isinstance(df.index, unicode):
df.index = df.index.astype(unicode)
错误信息:
TypeError: Setting <class 'pandas.core.index.Float64Index'> dtype to anything other than float64 or object is not supported
【问题讨论】:
标签: python pandas indexing dataframe rows