Back
How to convert real numpy array to int numpy array? Tried using map directly to array but it did not work.
To convert 2D float numpy array to 2D int numpy array you can use the astype method below is the code that explains how to use it:-
import numpy as npx = np.array([[1.0, 2.3], [1.3, 2.9]])print(x)x.astype(int)
import numpy as np
x = np.array([[1.0, 2.3], [1.3, 2.9]])
print(x)
x.astype(int)
31k questions
32.8k answers
501 comments
693 users