📜  numpy.ma.notmasked_contiguous函数| Python

📅  最后修改于: 2022-05-13 01:55:25.659000             🧑  作者: Mango

numpy.ma.notmasked_contiguous函数| Python

numpy.ma.notmasked_contiguous()函数在给定轴的掩码数组中查找连续的未掩码数据。

代码#1:

# Python program explaining
# numpy.ma.notmasked_contiguous() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.arange(12).reshape((3, 4))
mask = geek.zeros_like(arr)
mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0
ma = geek.ma.array(arr, mask = mask)
  
gfg = geek.ma.notmasked_contiguous(ma)
  
print (gfg)

输出 :


代码#2:

# Python program explaining
# numpy.ma.notmasked_contiguous() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.arange(12).reshape((3, 4))
mask = geek.zeros_like(arr)
mask[1:, :-1] = 1; mask[0, 1] = 1; mask[-1, 0] = 0
ma = geek.ma.array(arr, mask = mask)
  
gfg = geek.ma.notmasked_contiguous(ma, axis = 1)
  
print (gfg)

输出 :