On Sat, Jun 13, 2009 at 5:51 AM, fred wrote:
> Emmanuelle Gouillart a écrit :
>> Hi Fred,
> Hi Manue ;-)
>
>> here is another solution
> A = np.arange(99).reshape((33,3)
> mask = (A==np.array([0,1,2]))
> np.nonzero(np.prod(mask, axis=1))[0]
>> array([0]
>>
>> I found it to be less elega
Emmanuelle Gouillart a écrit :
> Hi Fred,
Hi Manue ;-)
> here is another solution
A = np.arange(99).reshape((33,3)
mask = (A==np.array([0,1,2]))
np.nonzero(np.prod(mask, axis=1))[0]
> array([0]
>
> I found it to be less elegant than Josef's solution changing the dtype of
> the arra
Hi Fred,
here is another solution
>>> A = np.arange(99).reshape((33,3)
>>> mask = (A==np.array([0,1,2]))
>>> np.nonzero(np.prod(mask, axis=1))[0]
array([0]
I found it to be less elegant than Josef's solution changing the dtype of
the array, but it may be easier to understand if you're not very fa
josef.p...@gmail.com a écrit :
> something like this should work to find rows with specific elements,
> if I understand you correctly.
You did ;-)
> np.nonzero(A.view([('',float)]*3) == np.array((1,2,3),[('',float)]*3))[0]
>
> It creates an extra dimension, that needs to be removed with [0], but
On Fri, Jun 12, 2009 at 7:08 PM, fred wrote:
> Hi,
>
> Say I have an array A with shape (10,3) and
>
> A[3,:] = [1,2,3]
>
> I want to find the index of the array in which I have these values [1,2,3].
>
> How can I do that?
>
> The only workaround I have found is to use a list:
>
> A.tolist().index(
Hi,
Say I have an array A with shape (10,3) and
A[3,:] = [1,2,3]
I want to find the index of the array in which I have these values [1,2,3].
How can I do that?
The only workaround I have found is to use a list:
A.tolist().index([1,2, 3])
That works fine, but is there a better solution (witho