Stop auto rounding in numpy

Viewed 77

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]
1 Answers

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

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