Problem Description : An error occurred while accessing the elements in the list: typeerror:only integer scalar arrays can is converted to a scalar index
1 Voteilabel = labels[sorteddistindicies[i]]
Suppose A is a list, and if you visit A[object] The above error, you can refer to the following content
Reason Description : This is typically because the object in A[object] is an integer, and the object you provide to the list is not an integer, so you cannot access the list element as an index to the list
recommendation : Use the statement print (type object) to see if the object you provided is an integer, and if not, just provide the integer as needed
For example, sorteddistindicies[i in the above code], I thought it was an integer, and the result is an array, so the compiler means that only a scalar integer can be used as a scalar index, and then I change the code to Sorteddistindicies[0][i] After getting an integer, by compiling the
Typeerror:only integer scalar arrays can be converted to a scalar index