[Numpy-discussion] numpy where function on different size
Sat Nov 24 14:51:07 CST 2012
> Message: 6
> Date: Sat, 24 Nov 2012 20:36:45 +0000
> From: Siegfried Gonzi <firstname.lastname@example.org>
> Subject: [Numpy-discussion] numpy where function on different size
> Hi all
>This must have been answered in the past but my google search
> capabilities are not the best.
>Given an array A say of dimension 40x60 and given another array/vector B
> of dimension 20 (the values in B occur only once).
>What I would like to do is the following which of course does not work
> (by the way doesn't work in IDL either):
>indx=where(A == B)
>I understand A and B are both of different dimensions. So my question:
> what would the fastest or proper way to accomplish this (I found a
> solution but think is rather awkward and not very scipy/numpy-tonic
I should clarify: where(A==B, C, A)
C is of equal dimension than B. Basically: everywhere where A equals e.g. B replace by C; or where B equals A replace very occurence in A by C.
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the NumPy-Discussion