On this page
numpy.ma.MaskedArray.toflex
method
- MaskedArray.toflex(self)[source]
- 
    Transforms a masked array into a flexible-type array. The flexible type array that is returned will have two fields: - the _datafield stores the_datapart of the array.
- the _maskfield stores the_maskpart of the array.
 - Parameters
- 
      - None
 
- Returns
- 
      - recordndarray
- 
        A new flexible-type ndarraywith two fields: the first element containing a value, the second element containing the corresponding mask boolean. The returned record shape matches self.shape.
 
 NotesA side-effect of transforming a masked array into a flexible ndarrayis that meta information (fill_value, …) will be lost.Examples>>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) >>> x masked_array( data=[[1, --, 3], [--, 5, --], [7, --, 9]], mask=[[False, True, False], [ True, False, True], [False, True, False]], fill_value=999999) >>> x.toflex() array([[(1, False), (2, True), (3, False)], [(4, True), (5, False), (6, True)], [(7, False), (8, True), (9, False)]], dtype=[('_data', '<i8'), ('_mask', '?')])
- the 
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.19/reference/generated/numpy.ma.MaskedArray.toflex.html