I’m using numpy loadtxt function to read in a large set of data. The data appears to be rounded off. for example: The number in the text file is -3.79000000000005E+01 but numpy reads the number in as -37.9. I’ve set the dypte to np.float64 in the loadtxt call. Is there anyway to keep the precision of the original data file?
Share
loadtxtis not rounding the number. What you are seeing is the way NumPy chooses to print the array:The actual value is the np.float64 closest to the value inputted.
Or, in the more likely instance that you have a higher dimensional array,
If the
reprofxlooks truncated:you can use
np.set_printoptionsto get higher precision:(Thanks to @mgilson for pointing this out.)