Issue
I have a 2d array that is stored with NumPy. Is it possible to only convert the first and second columns to integers from float?
This is my example of a 2d array.
Solution
You can use asType()
method
import numpy as np
arrayOfFloats = np.array(
[
[1.2, 2.2, 3.2],
[4.3, 5.4, 6.2]
]
)
arrayOfFloats[0:1, 0:2] = arrayOfFloats[0:1, 0:2].astype(np.int64)
print(arrayOfFloats)
Answered By - Overcode
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.