Python numpy.ma.flatnotmasked_edges()函数
numpy.ma.flatnotmasked_edges()函数找到第一个和最后一个未屏蔽的值的索引。
语法: numpy.ma.flatnotmasked_edges(arr)
参数 :
arr : [ array_like] 输入1-D MaskedArray。
返回 : [ndarray or None] 数组中第一个和最后一个非屏蔽值的索引。如果所有的值都被屏蔽了,则返回无。
代码#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