Key Concepts

Review core concepts you need to learn to master this subject

Indexing NumPy elements using conditionals

numbers = np.array([-5, 4, 0, 2, 3]) positives = numbers[numbers > 0] print(positives) # array([4, 2, 3])

NumPy elements can be indexed using conditionals. The syntax to filter an array using a conditional is array_name[conditional].

The returned array will contain only the elements for which the conditional evaluates to True.

Introduction to NumPy
Lesson 1 of 1

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo