Accessing NumPy array elements not in a given index list

The way you have your data, the simplest approach is to use np.delete:

sub_array = np.delete(array, index, axis=2)

Alternatively, the logical operators you were trying to use can be applied with boolean arrays as @DSM suggests:

mask = np.ones(a.shape[2], dtype=bool)
mask[index] = False
sub_array = array[:,:, mask]

(I wouldn’t call your array array but I followed the names in your question)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)