Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Data Science by (50.2k points)

I want to change a dataframes' index (rows) from float64 to string or Unicode.

I thought this would work but not:

#check type



#change type to unicode

if not isinstance(df.index, unicode):

    df.index = df.index.astype(unicode)

error message:

TypeError: Setting <class 'pandas.core.index.Float64Index'> dtype to anything other than float64 or object is not supported

1 Answer

0 votes
by (108k points)

For Python 2, you can refer the following code as this works for me:

df.index = 

And for Python 3, the unicode type does not exist and is replaced by str. Refer the following code:

df.index =

Related questions

Browse Categories