this is how you could change all values within an array from float to int:
# Example array
arr_float = [3.45, 5.6, 3.89, 10.1]
# to integer values
arr_int = [int(n) for n in arr_float] # this is a list comprehension
arr_int
>>> [3, 5, 3, 10] # float values to integer get always rounded down to whole number
Alternatively, you make the the array an numpy array and proceed like in your question:
import numpy as np
# Example array
arr_float = [3.45, 5.6, 3.89, 10.1]
# to numpy array
arr_np = np.array(arr_float)
arr_np.astype(int)
>>> array([ 3, 5, 3, 10])
This would be a function that is callable whenever you need to change:
# Function changing float values to integer values
def to_int(input_array):
return [int(n) for n in input_array]
# Example array
arr_float = [3.86, 2.9999, 9.46, 3.00013, 8.56]
to_int(arr_float)
>>> [3, 2, 9, 3, 8]