cast array to float python code example
Example 1: convert all values in array into float
import numpy as np
x = np.array(['1.1', '2.2', '3.3'])
y = x.astype(np.float)
Example 2: 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]])