Thursday, September 4, 2025
HomeLanguagesnumpy.ma.is_masked() function | Python

numpy.ma.is_masked() function | Python

numpy.ma.is_masked() function determine whether input has masked values & accepts any object as input, but always returns False unless the input is a MaskedArray containing masked values.

Syntax : numpy.ma.is_masked(arr)

Parameters :
arr : [array_like] Array to check for masked values.

Return : [bool] True if arr is a MaskedArray with masked values, False otherwise.

Code #1 :




# Python program explaining
# numpy.ma.is_masked() function
  
# importing numpy as geek 
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = ma.masked_equal([0, 1, 2, 0, 3], 0)
  
gfg = ma.is_masked(arr)
  
  
print (gfg)


Output :

True

 
Code #2 :




# Python program explaining
# numpy.ma.is_masked() function
  
# importing numpy as geek 
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = [True, False, True]
  
# always returns False unless
# the input is a MaskedArray 
gfg = ma.is_masked(arr)
  
print (gfg)


Output :

False
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32261 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6747 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6695 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS