📜  numpy.ma.clump_masked()函数| Python

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

numpy.ma.clump_masked()函数| Python

numpy.ma.clump_masked()函数返回对应于一维数组的掩码团块的切片列表。

代码#1:

# Python program explaining
# numpy.ma.clump_masked() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.ma.masked_array(geek.arange(8))
arr[[0, 1, 2, 6]] = geek.ma.masked
   
gfg = geek.ma.clump_masked(arr)
  
print (gfg)

输出 :

[slice(0, 3, None), slice(6, 7, None)]


代码#2:

# Python program explaining
# numpy.ma.clump_masked() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.ma.masked_array(geek.arange(10))
arr[[0, 1, 2, 6, 8, 9]] = geek.ma.masked
   
gfg = geek.ma.clump_masked(arr)
  
print (gfg)

输出 :

[slice(0, 3, None), slice(6, 7, None), slice(8, 10, None)]