Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

[Solved] TypeError: ‘numpy.float64’ object cannot be interpreted as an integer

# import numpy library
import numpy as np

# create array of values in pandas
my_array = np.array([2.5, 6.4, 2.1, 7.4, 8.9, 1.1])

# covert values of array to integer using astype()
my_array = my_array.astype(int)
print("Converted array is", my_array)

#  print the range of values using for loop
for i in range(len(my_array)):
    print(range(my_array[i]))
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #object #interpreted #integer
ADD COMMENT
Topic
Name
7+3 =