[SciPy-user] array manipulation

Robert Kern robert.kern@gmail....
Thu Oct 23 09:24:55 CDT 2008


On Thu, Oct 23, 2008 at 09:02, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
> Hi all,
>
>>>> M
> array([[1025338,       1,       1,       1],
>        [1036103,       1,       1,       1],
>        [2008297,       1,       1,       1],
>        [2086888,       0,       0,       1],
>        [2127079,       1,       0,       0],
>        [2157100,       0,       1,       0],
>        [2157969,       1,       1,       1],
>        [2222852,       1,       0,       1]])
>>>> 1025338 in M[:,0]
> True
>>>> 2157100 in M[:,0]
> True
>
> How can I obtain the row index of numbers that belong
> to M ?

searchsorted() if you can guarantee that the column is always sorted.
Otherwise nonzero(x == M[:,0])[0].

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the SciPy-user mailing list