Learn practical skills, build real-world projects, and advance your career

Masked Arrays

What's NumPy again?

Numpy is the core library for scientific computing in Python. It provides a high-performance multidimensional array object, and tools for working with these arrays.

Now let's get to the Masked Array part:

Masked arrays are arrays that have missing or invalid entries. The "numpy.ma" module is similar to numPy but it also enables us to work with masked arrays. A masked array contains both an array and a mask. The mask can be specified as an array of booleans that tells us whether each element of the array is valid or not. When the mask element is False, it means that the specified element is valid and vice versa. When no element in the array is invalid, the mask is designated "nomask".

The five functions that I have chosen are:

  • asarray
  • masked_invalid
  • fix_invalid
  • masked_where
  • mask_or
!pip install jovian --upgrade -q
import jovian
jovian.commit(project='numpy-array-operations')
[jovian] Attempting to save notebook..

Let's begin by importing Numpy and listing out the functions covered in this notebook.