numpy.ma.append() function | Python (original) (raw)
Last Updated : 22 Apr, 2020
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 :
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 :
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]
Similar Reads
- numpy.ma.filled() function - Python numpy.ma.filled() function return input as an array with masked data replaced by a fill value. If arr is not a MaskedArray, arr itself is returned. If arr is a MaskedArray and fill_value is None, fill_value is set to arr.fill_value. Syntax : numpy.ma.filled(arr, fill_value = None) Parameters : arr : 1 min read
- numpy.ma.choose() function - Python numpy.ma.choose() function use an index array to construct a new array from a set of choices. Given an array of integers and a set of n choice arrays, this method will create a new array that merges each of the choice arrays. Where arr value in arr is i, the new array will have the value that choice 2 min read
- numpy.append() in Python numpy.append() function is used to add new values at end of existing NumPy array. This is useful when we have to add more elements or rows in existing numpy array. It can also combine two arrays into a bigger one. Syntax: numpy.append(array, values, axis = None) array: Input array. values: The value 2 min read
- numpy.char.add() function in Python The add() method of the char class in the NumPy module is used for element-wise string concatenation for two arrays of str or unicode. numpy.char.add()Syntax : numpy.char.add(x1, x2)Parameters : x1 : first array to be concatenated (concatenated at the beginning)x2 : second array to be concatenated ( 2 min read
- numpy.concatenate() function | Python numpy.concatenate() function concatenate a sequence of arrays along an existing axis. Syntax : numpy.concatenate((arr1, arr2, ...), axis=0, out=None) Parameters : arr1, arr2, ... : [sequence of array_like] The arrays must have the same shape, except in the dimension corresponding to axis. axis : [in 2 min read
- numpy.add() in Python NumPy, the Python powerhouse for scientific computing, provides an array of tools to efficiently manipulate and analyze data. Among its key functionalities lies numpy.add() a potent function that performs element-wise addition on NumPy arrays. numpy.add() SyntaxSyntax : numpy.add(arr1, arr2, /, out= 4 min read
- numpy.char.multiply() function in Python The multiply() method of the char class in the NumPy module is used for element-wise string multiple concatenation. numpy.char.multiply()Syntax : numpy.char.multiply(a, i)Parameters : a : array of str or unicodei : number of times to be repeatedReturns : Array of strings Example 1 : Using the method 1 min read
- numpy.multiply() in Python The numpy.multiply() is a numpy function in Python which is used to find element-wise multiplication of two arrays or scalar (single value). It returns the product of two input array element by element. Syntax: numpy.multiply(arr1, arr2, out=None, where=True, casting='same_kind', order='K', dtype=No 3 min read
- sum() function in Python The sum of numbers in the list is required everywhere. Python provides an inbuilt function sum() which sums up the numbers in the list. [GFGTABS] Python arr = [1, 5, 2] print(sum(arr)) [/GFGTABS]Output8 Sum() Function in Python Syntax Syntax : sum(iterable, start) iterable : iterable can be anything 3 min read
- numpy.defchararray.add() in Python numpy.core.defchararray.add(arr1, arr2): Concatenates two strings element-wise. Parameters: arr1 : array-like or string. arr2 : array-like or string. Returns : Concatenates String. Code #1: # Python Program illustrating # numpy.char.add() method import numpy as np arr1 = ['vdteteAAAa', 'AAAttttds', 1 min read