How to use Int() function In Python
Here we will int() function to cast the array object before getting into range.
Python3
# code import numpy as np # an array of float values arr = np.array([ 1.5 , 2.5 , 3.5 ]) # we loop to print out range of values # at each index for i in range ( len (arr)): print ( range ( int (arr[i]))) |
Output:
range(0, 1) range(0, 2) range(0, 3)
How to Fix: ‘numpy.float64’ object cannot be interpreted as an integer
In this article, we are going to see how to fix: ‘numpy.float64’ object cannot be interpreted as an integer.
When a function or operation is applied to an object of the wrong type, a type error is raised. The ‘numpy.float64’ object cannot be interpreted as an integer is one example of this type of problem. Let’s see what we can do about that.