reading and writing csv in pandas changes cell values

后端 未结 2 1513
执笔经年
执笔经年 2020-12-22 08:22

I\'ve just started learning pandas and noticed a very strange behaviour, reading and writing csv files changes the values of the cells of the data frame.

before:

相关标签:
2条回答
  • 2020-12-22 08:39

    What you see in your output csv are the same values but with higher precision.

    0 讨论(0)
  • 2020-12-22 08:44

    for example:

    df.to_csv('pandasfile.csv', float_format='%.3f')
    
    0 讨论(0)
提交回复
热议问题