float object has no attribute round

Hyunjun Kim·2024년 11월 21일
0

Error

목록 보기
2/4

import numpy as np
a = np.random.rand(5)
a
array([0.92254859, 0.37214161, 0.35441334, 0.14139935, 0.40351668])
z = a.mean()
type(z)
<class 'numpy.float64'>
z
0.43880391309677796
z.round(3) # works OK with np.float64
0.439

b = 2.345
b.round(1) # fails with regular float
AttributeError: 'float' object has no attribute 'round'
type(b)
<class 'float'>

profile
Data Analytics Engineer 가 되

0개의 댓글