[Numpy-discussion] simple question
Christopher Barker
Chris.Barker at noaa.gov
Thu Jul 6 11:35:43 CDT 2006
Mathew Yeates wrote:
> ohhhh. I was looking at using "where"
There's nothing wrong with where:
>>> y = N.asmatrix(N.rand(3,3))
>>> y
matrix([[ 0.29741635, 0.78756994, 0.641378 ],
[ 0.0198837 , 0.71677631, 0.76068183],
[ 0.84904382, 0.80169706, 0.23877389]])
>>> x = N.asmatrix(N.where(y > 0.5, 1, 0))
>>> x
matrix([[0, 1, 1],
[0, 1, 1],
[1, 1, 0]])
And did you really mean matrix? or would 2-d arrays be fine?
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Numpy-discussion
mailing list