How to convert a NumPy array from float64 to int in Python

Converting a NumPy array from numpy.float64 to numpy.int converts each element in the array to an integer.

Solution for How to convert a NumPy array from float64 to int in Python : You can use numpy.ndarray.astype(dtype) to convert an array from numpy.float64 to numpy.int Call numpy.ndarray.astype(dtype) with dtype as numpy.int to create a copy of numpy.ndarray cast with type numpy.int.


how-to-convert-a-numpy-array-from-float64-to-int-in-python