Search
 
SCRIPT & CODE EXAMPLE
 

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]))
Comment

Issue 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])

#  print the range of values using for loop
for i in range(len(my_array)):
    print(range(my_array[i]))
Comment

PREVIOUS NEXT
Code Example
Python :: how to convert a axis label to non scientific notation in matploltlib 
Python :: python directed graph 
Python :: rectangle function numpy 
Python :: what does it mean when i get a permission error in python 
Python :: numpy.where() for substring 
Python :: one2many add tuple 
Python :: how to export schema in graphene django 
Python :: import curses module in python 
Python :: declare array with given size python 
Python :: python quick sort 
Python :: workbook select sheet python 
Python :: binarizer pyspark 
Python :: update cell in sheet by column name using pandas 
Python :: python time a code segment 
Python :: leetcode 206 python 
Python :: createdb psql 
Python :: python file is writable 
Python :: inverted trapezium pattern in python 
Python :: python check if dictionary empty 
Python :: queryset.raw() in django rest framework joining tables 
Python :: relation api profile does not exist django 
Python :: installing django on windows 
Python :: ternary operator using dictionary in Python 
Python :: check entries smaller 0 after groupby 
Python :: powershell not printing until ctrl c 
Python :: matplotlib annotate align center 
Python :: random email generator python 
Python :: pick random value from dictionary python 
Python :: python string index 
Python :: dataframe 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =