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

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

numpy.ma.mask_rows()函数| Python

在这个numpy.ma.mask_rows()函数中,屏蔽包含屏蔽值的二维数组的行。此函数是轴等于 0 的 mask_rowcols 的快捷方式。

代码#1:

Python3
# Python program explaining
# numpy.ma.mask_rows() function
 
# importing numpy as geek
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
 
arr = geek.zeros((4, 4), dtype = int)
arr[2, 2] = 1
 
arr = ma.masked_equal(arr, 1)
 
gfg = ma.mask_rows(arr)
 
print (gfg)


Python3
# Python program explaining
# numpy.ma.mask_rows() function
 
# importing numpy as geek 
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
 
arr = geek.zeros((5, 5), dtype = int)
arr[3, 3] = 1
  
arr = ma.masked_equal(arr, 1)
 
gfg = ma.mask_rows(arr)
 
print (gfg)


输出 :

[[0 0 0 0]
 [0 0 0 0]
 [-- -- -- --]
 [0 0 0 0]]


代码#2:

Python3

# Python program explaining
# numpy.ma.mask_rows() function
 
# importing numpy as geek 
# and numpy.ma module as ma
import numpy as geek
import numpy.ma as ma
 
arr = geek.zeros((5, 5), dtype = int)
arr[3, 3] = 1
  
arr = ma.masked_equal(arr, 1)
 
gfg = ma.mask_rows(arr)
 
print (gfg)

输出 :

[[0 0 0 0 0]
 [0 0 0 0 0]
 [0 0 0 0 0]
 [-- -- -- -- --]
 [0 0 0 0 0]]