NumPy array type change by division (int to float)
import numpy as np
a = np.array([3, 4, 7])
print(a.dtype) # int64
print(a.shape) # (3,)
x = (a / 2)
print(x) # [ 1.5 2. 3.5]
print(x.dtype) # float64
print(x.shape) # (3,)
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
import numpy as np
a = np.array([3, 4, 7])
print(a.dtype) # int64
print(a.shape) # (3,)
x = (a / 2)
print(x) # [ 1.5 2. 3.5]
print(x.dtype) # float64
print(x.shape) # (3,)