Skip to content
Related Articles

Related Articles

Improve Article

numpy.ma.masked_all_like() function | Python

  • Last Updated : 05 May, 2020

numpy.ma.masked_all_like() function return an empty masked array of the same shape and dtype as the array arr, where all the data are masked.

Syntax : numpy.ma.masked_all_like(arr)

Parameter :
arr : [ndarray] An array describing the shape and dtype of the required MaskedArray.

Return : [MaskedArray] A masked array with all data masked.

Code #1 :






# Python program explaining
# numpy.ma.masked_all_like() function
  
# importing numpy as geek 
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.zeros((4, 4), dtype = geek.float32)
  
gfg = ma.masked_all_like(arr)
  
print (gfg)

Output :

[[-- -- -- --]
 [-- -- -- --]
 [-- -- -- --]
 [-- -- -- --]]

 
Code #2 :




# Python program explaining
# numpy.ma.masked_all_like() function
  
# importing numpy as geek 
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.zeros((4, 3), dtype = geek.float32)
  
gfg = ma.masked_all_like(arr)
  
print (gfg)

Output :

[[-- -- --]
 [-- -- --]
 [-- -- --]
 [-- -- --]]

 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 :