Python Forum
getting trailing zeros with 1 during pandas read
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting trailing zeros with 1 during pandas read
#1
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.
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,628 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
Smile How to further boost the data read write speed using pandas tjk9501 1 1,215 Nov-14-2022, 01:46 PM
Last Post: jefsummers
  Can't read text file with pandas zinho 6 11,940 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 1,886 Apr-13-2020, 02:24 PM
Last Post: vipinct
  How to use Scipy.special to retrieve complex Poles / Zeros of Bessel Polynominal Detzi 2 1,746 Dec-31-2019, 10:45 AM
Last Post: Detzi
  Numpy saving and loading introduces zeros in the middle of every element DreamingInsanity 0 1,403 Dec-11-2019, 07:21 PM
Last Post: DreamingInsanity
  Removing hyphens and adding zeros sidney 3 2,862 Aug-14-2019, 01:48 PM
Last Post: sidney
  Read Nested JSON with pandas.io.json palo173 4 9,501 Apr-29-2019, 01:25 PM
Last Post: palo173
  read complex file with both pandas and not Diedro 1 2,851 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  Python read Password protected excel and convert to Pandas DataFrame FORTITUDE 2 16,979 Aug-30-2018, 01:08 PM
Last Post: FORTITUDE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020