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

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

numpy.ma.append()函数| Python

numpy.ma.append()函数将值附加到数组的末尾。

代码#1:

# Python program explaining
# numpy.ma.append() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr1 = ma.masked_values([1, 2, 3], 3)
arr2 = ma.masked_values([[4, 5, 6], [7, 8, 9]], 8)
  
gfg = ma.append(arr1, arr2)
  
print (gfg)

输出 :

[1 2 -- 4 5 6 7 -- 9]


代码#2:

# Python program explaining
# numpy.ma.append() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr1 = ma.masked_values([1, 2, 3, 4], 2)
arr2 = ma.masked_values([[5, 6, 7], [8, 9, 10]], 8)
  
gfg = ma.append(arr1, arr2)
  
print (gfg)

输出 :

[1 -- 3 4 5 6 7 -- 9 10]