I want to create a new_list which will contain only the items of my old_list which satisfy the condition that the index in an array of labels is 3. I am trying something like this:
new_list = [x for x in old_list if idx[x] == 3]
IndexError: arrays used as indices must be of integer (or boolean) type
But i am getting the following error because idx is an array. How can i solve this problem?
edited: Idx is an array of equal size with my original data which contains labels for them. So basically i want to create a new list which will contain only the items of my original list which e.g have the label 3.
I want to do something like this: cluster_a = [old_list[x] for x in idx if x == 3]
Clarification: my old list is a list containing 3d arrays and the idx is an equal size array containing a label for each 3d array of my list as i aforementioned. I am trying my best to explain the problem. If something is needed please tell me.


old_listlooks like?