Bottom Page

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.
Quote
#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

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Can't read text file with pandas zinho 6 3,554 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 316 Apr-13-2020, 02:24 PM
Last Post: vipinct
  Removing hyphens and adding zeros sidney 3 843 Aug-14-2019, 01:48 PM
Last Post: sidney
  Read Nested JSON with pandas.io.json palo173 4 5,513 Apr-29-2019, 01:25 PM
Last Post: palo173
  read complex file with both pandas and not Diedro 1 886 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  Python read Password protected excel and convert to Pandas DataFrame FORTITUDE 2 8,816 Aug-30-2018, 01:08 PM
Last Post: FORTITUDE
  Read CSV data into Pandas DataSet From Variable? Oliver 7 8,046 Jul-05-2018, 03:29 AM
Last Post: answerquest
  1 I cant read many stocks(list) with pandas-datareader from yahoo Davidii111 1 2,182 Dec-27-2017, 04:47 PM
Last Post: nilamo
  pandas restricting csv read to certain rows metalray 5 15,960 Dec-16-2017, 07:39 AM
Last Post: metalray

Forum Jump:


Users browsing this thread: 1 Guest(s)