numpy.ma.flatnotmasked_edges()函数| Python
numpy.ma.flatnotmasked_edges()
函数查找第一个和最后一个未屏蔽值的索引。
Syntax : numpy.ma.flatnotmasked_edges(arr)
Parameters :
arr : [ array_like] Input 1-D MaskedArray.
Return : [ndarray or None] The indices of first and last non-masked value in the array. Returns None if all values are masked.
代码#1:
# Python program explaining
# numpy.ma.flatnotmasked_edges() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
arr = geek.ma.arange(12)
gfg = geek.ma.flatnotmasked_edges(arr)
print (gfg)
输出 :
[ 0, 11]
代码#2:
# Python program explaining
# numpy.ma.flatnotmasked_edges() function
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
arr = geek.ma.arange(12)
arr[:] = geek.ma.masked
gfg = geek.ma.flatnotmasked_edges(arr)
print (gfg)
输出 :
None