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.
CodePudding user response:
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)