Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

How to convert real numpy array to int numpy array? Tried using map directly to array but it did not work.

1 Answer

0 votes
by (106k points)

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 np

x = np.array([[1.0, 2.3], [1.3, 2.9]])

print(x)

x.astype(int)

image

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...