numpy.ma.masked_all_like()函数| Python
numpy.ma.masked_all_like()
函数返回一个与数组 arr 具有相同形状和 dtype 的空屏蔽数组,其中所有数据都被屏蔽。
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.
代码#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)
输出 :
[[-- -- -- --]
[-- -- -- --]
[-- -- -- --]
[-- -- -- --]]
代码#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)
输出 :
[[-- -- --]
[-- -- --]
[-- -- --]
[-- -- --]]