Note

Numpy (21) 본문

Numpy

Numpy (21)

알 수 없는 사용자 2022. 8. 12. 12:00
728x90

How to print only 3 decimal places in python numpy array?

# Input
rand_arr = np.random.random((5,3))

# Create the random array
rand_arr = np.random.random([5,3])

# Limit to 3 decimal places
np.set_printoptions(precision=3)
rand_arr[:4]

# output
array([[ 0.443,  0.109,  0.97 ],
       [ 0.388,  0.447,  0.191],
       [ 0.891,  0.474,  0.212],
       [ 0.609,  0.518,  0.403]])

'Numpy' 카테고리의 다른 글

Numpy (23)  (0) 2022.08.14
Numpy (22)  (0) 2022.08.13
Numpy (20)  (0) 2022.08.11
Numpy (19)  (0) 2022.08.10
Numpy (18)  (0) 2022.08.09
Comments