Recall & Review
beginner
What is a masked array in numpy?
A masked array is like a regular array but with a mask that hides or ignores certain elements during computations. It helps handle missing or invalid data easily.
Click to reveal answer
beginner
How do you create a masked array in numpy?
You can create a masked array using
numpy.ma.array(data, mask=mask_array), where mask_array is a boolean array marking elements to hide.Click to reveal answer
intermediate
What happens when you perform operations on masked arrays?
Operations ignore the masked elements, so calculations like sums or means only consider visible data, avoiding errors from missing or invalid values.
Click to reveal answer
beginner
How can masked arrays help with real-world data?
They help handle missing or corrupted data points without removing entire rows or columns, making analysis more accurate and easier.
Click to reveal answer
beginner
What is the difference between a masked array and a regular numpy array?
A masked array has an extra mask that marks elements to ignore, while a regular array treats all elements equally without hiding any.
Click to reveal answer
What does the mask in a numpy masked array do?
✗ Incorrect
The mask is a boolean array that marks which elements to ignore during computations.
How do masked arrays handle missing data?
✗ Incorrect
Masked arrays hide missing or invalid data using a mask, so calculations ignore those elements.
Which numpy module provides masked array functionality?
✗ Incorrect
The masked array functions are in the numpy.ma module.
What is the output of sum on a masked array with some masked elements?
✗ Incorrect
Sum ignores masked elements and adds only visible data.
Which of these is a valid way to create a masked array?
✗ Incorrect
The correct way is to use numpy.ma.array with a mask argument.
Explain what a masked array is and why it is useful in data analysis.
Think about how you handle missing data in a spreadsheet.
You got /4 concepts.
Describe how you would create a masked array in numpy and perform a sum ignoring certain values.
Remember the mask is a boolean array matching the data.
You got /4 concepts.