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
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.
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't read text file with pandas zinho 6 4,359 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 488 Apr-13-2020, 02:24 PM
Last Post: vipinct
  How to use Scipy.special to retrieve complex Poles / Zeros of Bessel Polynominal Detzi 2 477 Dec-31-2019, 10:45 AM
Last Post: Detzi
  Numpy saving and loading introduces zeros in the middle of every element DreamingInsanity 0 437 Dec-11-2019, 07:21 PM
Last Post: DreamingInsanity
  Removing hyphens and adding zeros sidney 3 1,054 Aug-14-2019, 01:48 PM
Last Post: sidney
  Read Nested JSON with palo173 4 6,193 Apr-29-2019, 01:25 PM
Last Post: palo173
  read complex file with both pandas and not Diedro 1 1,103 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  Python read Password protected excel and convert to Pandas DataFrame FORTITUDE 2 10,480 Aug-30-2018, 01:08 PM
  Read CSV data into Pandas DataSet From Variable? Oliver 7 8,866 Jul-05-2018, 03:29 AM
Last Post: answerquest
  1 I cant read many stocks(list) with pandas-datareader from yahoo Davidii111 1 2,492 Dec-27-2017, 04:47 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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