I have a test.csv file containing the following data:
id code
1000 60
1001 54
1002 60
1003 28
I read in .csv file into python. the columns are all 'int64'. I set 'id' as index, and want to convert the 'code' to string. I used the following code:
test = pd.read_csv("test.csv")
test = test.set_index('id')
test['code'] = test.to_string(columns = ['code'])
This is what I got in the new dataframe:
id code
1000 code
id 1000 60
1001 code
id 1000 60
1002 code
id 1000 60
1003 code
id 1000 60
What's wrong with my code?
Thank you so much!