Learn how to use boolean mask techniques for NumPy variables in this video tutorial by Charles Kelly. These are explained in the context of computer science and data science to technologists and students in preparation for machine learning, applied statis
- View Offline
- Exercise Files
- [Instructor] When you open the Boolean Mask Arrays file…in the exercises folder you'll see that it is pre-populated…with a numpy import statement,…and with a variable called my vector,…which is populated with a python list.…Before you begin using this interactive notebook,…you want to execute both of theses cells.…You can execute them both separately,…or you can go to the cell menu and select run all.…After you've selected run all you'll see that the values…in my vector are now in ND array,…and the values of the elements are exactly the same…as the values in the python list.…
Now I'm going to cut and paste the next cell…from the exercises file.…In it, I'm creating a new variable called…zero mod seven mask.…It takes on the values where my vector…is exactly divisible by seven.…In particular, the percentage sign is the remainder operator…and we're selecting all elements in the array…where the remainder after division…by seven is equal to zero.…I'm pressing shift + enter.…
We see that we've created an array of Boolean values.…
- Using Jupyter Notebook
- Creating NumPy arrays from Python structures
- Slicing arrays
- Using Boolean masking and broadcasting techniques
- Plotting in Jupyter notebooks
- Joining and splitting arrays
- Rearranging array elements
- Creating universal functions
- Finding patterns
- Building magic squares and magic cubes with NumPy and Python
Skill Level Intermediate
2. Create NumPy Arrays
3. Index, Slice, and Iterate
4. Plots: Matplotlib and Pyplot
5. Manipulate Arrays
6. Short Examples
7. Extended Examples
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
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.