Numpy MaskedArray.resize() function | Python Last Updated : 03 Oct, 2019 Comments Improve Suggest changes Like Article Like Report numpy.MaskedArray.resize() function is used to a make a new masked array with the specified size and shape from the given array.The new array is filled with repeated copies of arr (in the order that the data are stored in memory). If arr is masked, the new array will be masked, and the new mask will be a repetition of the old one. Syntax : numpy.ma.resize(arr, new_shape) Parameters: arr: The input array which to be resized. new_shape:[ int or tuple of ints] The new shape of resized array. Return : [ resized_array] A new shape of the array. Code #1 : Python3 # Python program explaining # numpy.MaskedArray.resize() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array of 2 * 2 in_arr = geek.array([[10, 20], [-10, 40]]) print ("Input array : ", in_arr) # Now we are creating a masked array. # by making one entry as invalid. mask_arr = ma.masked_array(in_arr, mask =[[ 1, 0], [ 0, 0]]) print ("Masked array : ", mask_arr) # applying MaskedArray.resize methods to make # it a 3 * 3 masked array out_arr = ma.resize(mask_arr, (3, 3)) print ("Output resized masked array : ", out_arr) Output: Input array : [[ 10 20] [-10 40]] Masked array : [[-- 20] [-10 40]] Output resized masked array : [[-- 20 -10] [40 -- 20] [-10 40 --]] Code #2 : Python3 # Python program explaining # numpy.MaskedArray.resize() method # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma # creating input array in_arr = geek.array([[[ 2e8, 3e-5]], [[ -4e-6, 2e5]]]) print ("Input array : ", in_arr) # Now we are creating a masked array. # by making one entry as invalid. mask_arr = ma.masked_array(in_arr, mask =[[[ 1, 0]], [[ 0, 0]]]) print ("Masked array : ", mask_arr) # applying MaskedArray.resize methods to make # it a 1 * 6 masked array out_arr = ma.resize(mask_arr, (1, 6)) print ("Output resized masked array : ", out_arr) Output: Input array : [[[ 2.e+08 3.e-05]] [[-4.e-06 2.e+05]]] Masked array : [[[-- 3e-05]] [[-4e-06 200000.0]]] Output resized masked array : [[-- 3e-05 -4e-06 200000.0 -- 3e-05]] ? Comment More infoAdvertise with us Next Article Numpy MaskedArray.resize() function | Python J jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-arrayManipulation Practice Tags : python Similar Reads Numpy MaskedArray.reshape() function | Python numpy.MaskedArray.reshape() function is used to give a new shape to the masked array without changing its data.It returns a masked array containing the same data, but with a new shape. The result is a view on the original array; if this is not possible, a ValueError is raised. Syntax : numpy.ma.resh 3 min read numpy.ndarray.resize() function - Python numpy.ndarray.resize() function change shape and size of array in-place. Syntax : numpy.ndarray.resize(new_shape, refcheck = True) Parameters : new_shape :[tuple of ints, or n ints] Shape of resized array. refcheck :[bool, optional] If False, reference count will not be checked. Default is True. Ret 1 min read Numpy MaskedArray.ravel() function | Python numpy.MaskedArray.ravel() function is used to return a 1D version of self mask array, as a view. Syntax : numpy.ma.ravel(self, order='C') Parameters: order : [âCâ, âFâ, âAâ, âKâ, optional] By default, âCâ index order is used. --> The elements of a are read using this index order. --> âCâ means to in 2 min read Numpy MaskedArray.sum() function | Python numpy.MaskedArray.median() function is used to compute the sum of the masked array elements over the given axis. Syntax : numpy.ma.sum(arr, axis=None, dtype=None, out=None, keepdims=False) Parameters: arr : [ ndarray ] Input masked array. axis :[ int, optional] Axis along which the sum is computed. 3 min read Numpy MaskedArray.std() function | Python numpy.MaskedArray.std() function is used to compute the standard deviation along the specified axis.Here masked entries are ignored. The standard deviation is computed for the flattened array by default, otherwise over the specified axis. Syntax : numpy.ma.std(arr, axis=None, dtype=None, out=None, d 3 min read Like