0

I have a dataframe column which had more than 14 digits, which may sometimes run upto 20 digits.

Issue i'm facing is, once i have read the csv file using pd.read_csv() rows having long numeric values get truncated / rounded off to next number eg Original row value = 10173555000199, after reading csv file to pandas, value changed to = 10173600000000. Not sure why this is happening.

Is there a way to avoid this while reading data through csv file?

Sid
  • 163
  • 7
  • that's not normal, but might be due to the data type, try setting `dtype` to np.int64 for example for your column and see what happens in the `pd.read_csv()` function. Also can you share with us a portion of your data ? – mrCopiCat Jun 01 '22 at 10:32
  • @mrCopiCat Issue is numbers are changing the minute I read the data, at a point where it does not matter even if i convert the column. Also the I tried the details shared for a similar question. It does not solve the issue – Sid Jun 01 '22 at 10:38
  • what i meant by setting the time is setting it inside the pd.read_csv() function like : `df = pd.read_csv(path_to_file, dtype={'values': np.int64})` can you try like that ? – mrCopiCat Jun 01 '22 at 10:41
  • @mrCopiCat some of the numbers ```Numbers 10173555000199 10277092000105 10325444000150``` – Sid Jun 01 '22 at 10:46
  • @mrCopiCat I tried the above code suggested. output remains truncated numbers – Sid Jun 01 '22 at 10:47
  • @mrCopiCat Can you please unblock the question. solution is not there in the link shared above – Sid Jun 01 '22 at 10:53
  • did you, by any chance open the file with excel ? I know it seems weird as a qst but excel have a huuge tendency to ruining csv data – mrCopiCat Jun 01 '22 at 10:54
  • Yes, It is an excel file which I converted to csv and read the data to python – Sid Jun 01 '22 at 11:00

0 Answers0