Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

[Solved]AttributeError: ‘numpy.ndarray’ object has no attribute ‘index’

# import numpy library
import numpy as np

# create NumPy array
my_array = np.array([3, 5, 2, 1, 6, 9, 8, 4])

# find the largest number in numpy array
largest_num = np.max(my_array)
print("Largest number in array is", largest_num)

# print the index of largest number
print(np.where(my_array == largest_num))
Comment

Issue AttributeError: ‘numpy.ndarray’ object has no attribute ‘index’

# import numpy library
import numpy as np

# create NumPy array
my_array = np.array([3, 5, 2, 1, 6, 9, 8, 4])

# find the largest number in numpy array
largest_num = np.max(my_array)
print("Largest number in array is", largest_num)

# find the index of largest number
my_array.index(largest_num)
Comment

PREVIOUS NEXT
Code Example
Python :: quiz game in python 
Python :: pandas count distinct values in column 
Python :: lstm pytorch documentation 
Python :: while loop in python for do you want to continue 
Python :: python if loop 
Python :: update python version pycharm 
Python :: what does tuple mean in python 
Python :: program in python to print first 10 natural number. 
Python :: python else 
Python :: drop null values in dataframe 
Python :: naive bayes implementation in python 
Python :: print multiple strings in python 
Python :: python string: immutable string 
Python :: how to reduce the image files size in python 
Python :: how to check if a string value is nan in python 
Python :: count true in a dataframe 
Python :: python quiz answer stores 
Python :: how to generate two random numbers in python 
Python :: diccionario python 
Python :: python tkinter get entry text 
Python :: how to check if string ends with specific characters in python 
Python :: pandas extracting tables from pdf 
Python :: how to block a ip adress 
Python :: pyglet on button press 
Python :: print items of list using list comprehension in python 
Python :: len 
Python :: extract x y coordinates from image in pdf python 
Python :: projects for beginners in python to complete 
Shell :: classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap 
Shell :: emu8086 registration key 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =