[Numpy-discussion] get information/position of value from matrix
ioannis syntychakis
ioannis87 at gmail.com
Thu Apr 8 03:06:16 EDT 2010
thanks for all your answers.
Now i can get al the values above the 150, but i would also like to have
their positions in de matrix.
excample:
[[1. 4. 5. 6. 7. 1
2. 5. 7. 8. 9. 3
3. 5. 7. 1. 3. 7]]
so, if i now look for values above the 8. the ouput should be; 1 value on
position (4,1) (beginnning from 0)
is this possible? thanks in advance!!!
2010/4/7 Ian Mallett <geometrian at gmail.com>
> On Wed, Apr 7, 2010 at 7:40 AM, ioannis syntychakis <ioannis87 at gmail.com>wrote:
>
>> Hallo Everybody,
>>
>> I am new in this mail list and python. But I am working at something and I
>> need your help.
>>
>> I have a very big matrix. What I want is to search in that matrix for
>> values above the (for example:) 150. If there are values above the 150, I
>> also want to get their position and value.
>>
> I think:
>
> your_matrix = #
> indices = np.where(matrix>150.0)
> values = your_matrix[indices]
>
> should work.
>
>> Is this possible?
>> Thanks in advance!!
>>
>> ps. could you also tell me how i can show the whole matrix? because now i
>> see:
>>
>> [[ 0. 0. 0. ..., 87. 4. 4.]
>> [ 0. 0. 0. ..., 89. 6. 4.]
>> [ 0. 1. 0. ..., 87. 4. 3.]
>> ...,
>> [ 0. 0. 0. ..., 87. 4. 4.]
>> [ 0. 3. 0. ..., 87. 4. 4.]
>> [ 0. 0. 4. ..., 87. 4. 4.]]
>>
> set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None, nanstr=None, infstr=None)
>
> Ian
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100408/56d2051c/attachment.html>
More information about the NumPy-Discussion
mailing list