filmov
tv
Python: Array Masks

Показать описание
Comment for any questions.
This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.
ARRAY MASKING
array masking is a powerful coding tool and I will show you how it works here.
First, so we can make matrices we import numpy as np
And today I’ll show you with a random matrix so we will import random.
First we will make a random 5x5 matrix with entries between -5 and 5.
So here is our random 5x5 matrix A
And now we will create the mask. Let’s call this mask, though you can name it anything.
We will do a mask that is anywhere A is greater than 0
When we print out the mask it will be a matrix the same size as A with boolean values in every spot. True where the value is greater than 0 and False where the value is less than 0
Once we have this mask we can type A[mask]
This will be all the values of A that satisfy the mask.
So here it is, all the positive numbers in A
And Let’s show you A again.
There you have it, that is how you do numpy array masking
#PythonMarathon #LearnPython #PythonTutorial Learn Python:
Video Equipment:
Other:
Комментарии