Skip to content
Related Articles

Related Articles

Improve Article

numpy.ma.is_masked() function | Python

  • Last Updated : 05 May, 2020

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

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :