Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
python
numpy
communitycreator

What is the numpy.ma.masked_all() function in Python?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The ma.masked_all() function in Python is used to empty a masked array of the given shape and data type with all elements masked.

Syntax

ma.masked_all(shape, dtype=<class 'float'>)

Parameters

The ma.masked_all() function takes the following parameter values:

  • shape: This represents the shape of the output masked array.
  • dtype: This represents the data type of the output array. This is optional.

Return value

The ma.masked_all() function returns a masked array where all elements are masked.

Example

import numpy as np
import numpy.ma as ma

# implementing the `ma.masked_all()` function 
myarray = ma.masked_all((2,3), dtype=np.float)

# printing the array
print(myarray)
Implementing the `ma.masked_all()` function

Explanation

  • Line 1–2: We import the necessary modules and libraries.
  • Line 5: We implement the ma.masked_all() function using a shape of 2 by 3 and a float dtype for the output array. The result is stored in myarray.
  • Line 8: We print the masked array myarray.

RELATED TAGS

function
python
numpy
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring