numpy to int python code example
Example 1: np convert to int
>>> x = np.array([[1.0, 2.3], [1.3, 2.9]])
>>> x
array([[ 1. , 2.3],
[ 1.3, 2.9]])
>>> x.astype(int)
array([[1, 2],
[1, 2]])
Example 2: numpy int64 to int
import numpy as np
val = np.float32(0)
pyval = val.item()
print(type(pyval))
type(np.float64(0).item())
type(np.uint32(0).item())
type(np.int16(0).item())
type(np.cfloat(0).item())
type(np.datetime64(0, 'D').item())
type(np.datetime64('2001-01-01 00:00:00').item())
type(np.timedelta64(0, 'D').item())
...