numpy.ma.is_masked()函数| Python
numpy.ma.is_masked()
函数确定输入是否具有屏蔽值并接受任何对象作为输入,但始终返回 False,除非输入是包含屏蔽值的 MaskedArray。
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.
代码#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)
输出 :
True
代码#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)
输出 :
False