Issue
How do I convert a float NumPy array into an int NumPy array?
Solution
Use the astype
method.
>>> 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]])
Answered By - BrenBarn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.