[SciPy-user] numpy indexing with arrays

Jeremy Sanders jeremy@jeremysanders....
Wed Dec 10 08:46:43 CST 2008


Pauli Virtanen wrote:

>>>> import numpy as np
>>>> vals = np.array([1.1, 2.2, 3.3, 4.4])
>>>> img = np.array([[0,1,2],[1,2,3]])
>>>> vals[img]
> array([[ 1.1,  2.2,  3.3],
>        [ 2.2,  3.3,  4.4]])
> 
> See
> 
> http://docs.scipy.org/doc/numpy/user/basics.indexing.html
> http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

Thanks - I thought I had tried this and it had failed.

Jeremy




More information about the SciPy-user mailing list