The Numpy array allows a list of indexes, e.g.
a = np.arange(1000) l = list([1,44,66,33,90,345]) a[l] = 22
But this method does not work if we want, for example, to use indexing or indexes with several fragments, as well as a slice.
a = np.arange(1000) l = list([1,44,66,33,90, slice(200,300) , slice(500,600) ]) a[l] = 22
This code returns an error message:
IndexError: too many indices
My question is very simple: did you know that in numpy or scipy there is an effective method for using this kind of indexing?
Or what a good and effective way to use this indexing method?
Remember that using slices creates very fast code; and my problem is to have the code as fast as possible.
python arrays numpy indexing
Giggi
source share