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
  Can't read text file with pandas zinho 6 3,709 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 365 Apr-13-2020, 02:24 PM
Last Post: vipinct
  Numpy saving and loading introduces zeros in the middle of every element DreamingInsanity 0 330 Dec-11-2019, 07:21 PM
Last Post: DreamingInsanity
  Removing hyphens and adding zeros sidney 3 885 Aug-14-2019, 01:48 PM
Last Post: sidney
  Read Nested JSON with pandas.io.json palo173 4 5,656 Apr-29-2019, 01:25 PM
Last Post: palo173
  read complex file with both pandas and not Diedro 1 935 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  Python read Password protected excel and convert to Pandas DataFrame FORTITUDE 2 9,153 Aug-30-2018, 01:08 PM
Last Post: FORTITUDE
  Read CSV data into Pandas DataSet From Variable? Oliver 7 8,223 Jul-05-2018, 03:29 AM
Last Post: answerquest
  1 I cant read many stocks(list) with pandas-datareader from yahoo Davidii111 1 2,242 Dec-27-2017, 04:47 PM
Last Post: nilamo
  pandas restricting csv read to certain rows metalray 5 16,068 Dec-16-2017, 07:39 AM
Last Post: metalray

Forum Jump:

User Panel Messages

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