Ricardo
Ricardo

Reputation: 87

to csv seems to destroy some decimal values

enter image description here

Calculator on the left shows the correct number. In the source frame and when printing the frame instantly before the to_csv, everything is fine. Anyone got an idea what could happen? I googled into oblivion but can't seem to solve it.

Upvotes: 0

Views: 80

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54687

It's not destroying any values. The number 3521.12 cannot be represented exactly in binary. It's an infinitely repeating decimal. Your calculator, your frame view, and your frame print are all rounding that value to make it easier for you to read, as it should. The csv is storing the exact decimal value. When you read it back in, it will once again display correctly. That's just the way floating point works.

Upvotes: 3

Related Questions