Python: Array Masks

preview_player
Показать описание


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:
Рекомендации по теме
Комментарии
Автор

I've watched different tutorials and found your energetic, entertaining presentation effective for keeping my attention. I majored in math and I can say that there is a shortage of upbeat educators in that subject.

debitsandcreditsclub
Автор

Simply explained. I was trying to find some material on this topic and then I found your video. Thank you so much for making this video. Keep up the good work. ❤ from India.

killeraloo
Автор

Thank you so much for this tutorial. Perfect for quick revising after not having used python for years. Really helpful!

skyleigh
Автор

Thank you so much!!!! Your tutorial is so much better than my current textbook.

irisx
Автор

Hi Rylan. Thank you so much for your tutorial. it is really helpful. However I face a problem here. so I have an array x with 10x10 size and have been able to mask. But when I want to reveal the intended value, the size of array changes. how toshow the true value but with the same size?

kurdiyankurdiyan
Автор

can you do the same with multiple dimensions. take_along_axis()

donfeto
Автор

Hi, is there any tutorial about volume rendering with vtk python using mask

assiashabeeba