How to rightly locate a value at an index in nd array and save it as list in python?
问题 I have a list called L. It has C number of elements. I have a nd array called X. X has Boolean data (either 0 or 1). It has dimension as (20,C). There are 20 lists with each list having C number of elements I want to locate each index that has value of 1 in X.Then I want the value at this same index in List L, and finally store this value from L in another nd array . I write the following code emptylist=[] for index,value in np.ndenumerate(X): #this index is a tuple like (0,3) tuple_to_list