Learn how to use boolean indexing with NumPy arrays. Boolean indexing allows use to select and mutate part of array by logical conditions and arrays of boolean values (True or False).
- [Instructor] Sometimes, we'd like to select…parts of an array not by indices,…but by some logic.…Say all the values that are bigger than some threshold.…For this, we're going to use Boolean indexing.…Let's see how it works.…We already have imported numpy,…so we can start using it right away.…Let's create an array np dot arange of three.…We can index the array with another array…in the same shape with contained Boolean values…true or false.…This indexing array is like a mask…which will pick only the values from the original array…where the index array is true.…
That sounded a bit complex.…So, let's try an example to clear this up.…Array and, as an index, I'll parse another array…with true, false, and true.…We got only zero and two, which corresponds…to the true values in the array we parsed as an index.…For now, this does not seem that helpful.…Let's see one more thing that will make it super helpful.…We can say array, where it's bigger or equal to one.…
We got back an array of true and false.…The first item is false since array zero is zero…
- Working with Jupyter notebooks
- Using code cells
- Extensions to the Python language
- Markdown cells
- Editing notebooks
- NumPy basics
- Broadcasting, array operations, and ufuncs
- Folium and Geo
- Machine learning with scikit-learn
- Plotting with matplotlib and bokeh
- Branching into Numba, Cython, deep learning, and NLP
Skill Level Intermediate
1. Scientific Python Overview
2. The Jupyter Notebook
3. NumPy Basics
Manage environments5m 11s
6. Folium and Geo
7. NY Taxi Data
10. Other Packages
11. Development Process
Next steps1m 33s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.