Home > Net >  Stop auto rounding in numpy
Stop auto rounding in numpy

Time:01-18

I have this code but in the result, the values are converted to integers. I want the real value. How? Thank you for your help.


import numpy as np

a=np.array([1,2,3,4])

f=np.array([0.00020,0.0001])

for i in range(2):
    a[i]=f[i]
print(a)
# [0 0 3 4]

CodePudding user response:

a is an array of integers, you have to set it to a float array

a=np.array([1,2,3,4], dtype=float)
  •  Tags:  
  • Related