numpy.MaskedArray.flatten() function is used to return a copy of the input masked array collapsed into one dimension.
Syntax : numpy.ma.flatten(order='C')
Parameters:
order : [‘C’, ‘F’, ‘A’, ‘K’, optional] Whether to flatten in C (row-major), Fortran (column-major) order, or preserve the C/Fortran ordering from a. The default is ‘C’.
Return : [ ndarray] A copy of the input array, flattened to one dimension.
Code #1 :
Output:
Input array : [[ 10 20]
[-10 40]]
Masked array : [[-- 20]
[-10 40]]
Output flattened masked array : [-- 20 -10 40]
Code #2 :