AttributeError:'numpy.ndarray' object has no attribute 'index'

created at 06-26-2021 views: 22

description

Haven used Python for a while, I found that a negligible ndarray and list are different. 
First above: 

import numpy as np
array = [[0,0],[0,1],[0,2],[2,2],[3,3],[4,4]] 
Indexs = [1,2,3] 
print("first array:",array)
array = np.delete(array,Index,0)
print("second array:",array) 
print(array.index([0,0]))

operation result: 

first array: [[0, 0], [0, 1], [0, 2], [2, 2], [3, 3], [4, 4]] 
second array: [[0 0] 
[3 3] 
[4 4]] 
Traceback (most recent call last): 
File "C:\Users\admin\Desktop\meanshift\TEST.py", line 10, in <module> 
print(array.index([0,0])) 
AttributeError: 'numpy.ndarray' object has no attribute 'index'

It can be seen that the results of the List array and .ndarray are also different. 
The error 'numpy' Object Has No Attribute 'INDEX' is reported because numpy.Delete () returns ndarray after the index object is ndarray instead of list, so you can't use the location of Index lookup elements. 

solution ndarray.tolist ()

import numpy as np
array = [[0,0],[0,1],[0,2],[2,2],[3,3],[4,4]]
Indexs = [1,2,3] 
print("first array:",array) 
array = np.delete(array,Index,0) 
array = array.tolist() 
array = array.tolist() 
print("second array:",array) 
print(array.index([4,4]))

Experimental results:

first array: [[0, 0], [0, 1], [0, 2], [2, 2], [3, 3], [4, 4]] 
second array: [[0, 0], [3, 3], [4, 4]] 
2 

not its ok!!!

created at:06-26-2021
edited at: 07-09-2021: