Thursday, October 2, 2025
HomeLanguagesnumpy.ma.append() function | Python

numpy.ma.append() function | Python

numpy.ma.append() function append the values to the end of an array.

Syntax : numpy.ma.append(arr1, arr2, axis = None)
Parameters :
arr1 : [array_like] Values are appended to a copy of this array.
arr2 : [array_like] Values are appended to a copy of this array. If axis is not specified, arr2 can be any shape and will be flattened before use. Otherwise, it must be of the correct shape.
axis : [int, optional] The axis along which value are appended.
Return : [MaskedArray] A copy of arr1 with arr2 appended to axis. If axis is None, the result is a flattened array.

Code #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)


Output :

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

 
Code #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)


Output :

[1 -- 3 4 5 6 7 -- 9 10]
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11927 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7079 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS