Python Forum

Full Version: getting trailing zeros with 1 during pandas read
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.