I have a dataframe column 'rating' with floats and one of its values is:
3.63043
My following code changed it to:
3.6304300000000000
The code is simply replace the sep ',' with '\t':
df = pd.read_csv('test.csv', encoding='utf8', sep=',')
#df = df.astype({"raing": str})
df.to_csv('test.2.csv', encoding='utf8', sep='\t', index=False)
If I use the commented out code to specify the rating as str. It not only still produces the very long float number, but also introduced a new problem. Some cells are empty originally, and now in the new test2.csv, those empty cells are 'nan' which isn't desired.
I just want to replace the ',' with '\t' and nothing else needs to be changed. What's the right way to do that?