Python Forum
getting trailing zeros with 1 during pandas read - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: getting trailing zeros with 1 during pandas read (/thread-23553.html)



getting trailing zeros with 1 during pandas read - fullstop - Jan-05-2020

I am reading a simple csv file with multiple columns.
One of my column have 2 different values, one is 1.444 and other is 1.908
When I am reading the csv using
df = pd.read_csv('file.csv')
i got correct values for 1.444
but for 1.908 I am getting 1.9080000000000001
Why these extra '0's with '1' in the end. How can I avoid this.


RE: getting trailing zeros with 1 during pandas read - ichabod801 - Jan-05-2020

This is just an artifact of floating point numbers. Floating point numbers (which most computer programs use for decimal numbers) are not stored in a way that is always exactly precise. So sometimes you get those teeny little bits on the end. If you don't do a ton of calculations, you can generally just ignore them by just ignoring digits above a certain precision threshold.