1

I have a ndarray type array, for example:

1, 2, 0.5
2, 6, 0.9
9, 2, 0.83

I want to keep the rows whose 3rd elements are larger than 0.8, and discard the other rows. It means I want this result:

2, 6, 0.9
9, 2, 0.83

How can I finish the task?

1 Answer 1

2

Here is a simple implementation of your problem:

import numpy as np
data = np.array([[1, 2, 0.5],[2, 6, 0.9],[9, 2, 0.83]])
result =data[data[:,2]>0.8]

Output:

[[ 2.    6.    0.9 ]
[ 9.    2.    0.83]]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.