numpy.ma.fix_invalid() function | Python (original) (raw)
Last Updated : 05 May, 2020
numpy.ma.fix_invalid()
function return input with invalid data masked and replaced by a fill value. Where invalid data means values of nan, inf, etc.
Syntax : numpy.ma.fix_invalid(arr, mask = False, copy = True, fill_value = None)
Parameter :
arr : [array_like] Input array.
mask : [sequence, optional] Must be convertible to an array of booleans with the same shape as data. True indicates a masked data.
copy : [bool, optional] Whether to use a copy of a (True) or to fix a in place (False). Default is True.
fill_value : [scalar, optional] Value used for fixing invalid data. Default is None, in which case the arr.fill_value is used.Return : [MaskedArray] The input array with invalid entries fixed.
Code #1 :
import
numpy as geek
arr
=
geek.ma.array([
1.
,
-
1
, geek.nan, geek.inf],
`` mask
=
[
1
]
+
[
0
]
*
3
)
gfg
=
geek.ma.fix_invalid(arr)
print
(gfg)
Output :
[-- -1.0 -- --]
Code #2 :
import
numpy as geek
arr
=
geek.ma.array([
1.
,
-
1
, geek.nan,
`` geek.inf,
-
1
, geek.nan],
`` mask
=
[
1
]
+
[
0
]
*
5
)
gfg
=
geek.ma.fix_invalid(arr)
print
(gfg)
Output :
[-- -1.0 -- -- -1.0 --]
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.is_mask() function | Python numpy.ma.is_mask() function return True if parameter m is a valid, standard mask. This function does not check the contents of the input, only that the type is MaskType. In particular, this function returns False if the mask has a flexible dtype. Syntax : numpy.ma.is_mask(m) Parameter : m : [array_l 1 min read
- numpy.ma.is_masked() function | Python numpy.ma.is_masked() function determine whether input has masked values & accepts any object as input, but always returns False unless the input is a MaskedArray containing masked values. Syntax : numpy.ma.is_masked(arr) Parameters : arr : [array_like] Array to check for masked values. Return : 1 min read
- Numpy MaskedArray.masked_invalid() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 2 min read
- numpy.ma.masked_all_like() function | Python numpy.ma.masked_all_like() function return an empty masked array of the same shape and dtype as the array arr, where all the data are masked. Syntax : numpy.ma.masked_all_like(arr) Parameter : arr : [ndarray] An array describing the shape and dtype of the required MaskedArray. Return : [MaskedArray] 1 min read
- numpy.mintypecode() function – Python numpy.mintypecode() function return the character for the minimum-size type to which given types can be safely cast. Syntax : numpy.mintypecode(typechars, typeset = 'GDFgdf', default = 'd') Parameters : typechars : [list of str or array_like] If a list of strings, each string should represent a dtyp 1 min read
- Numpy MaskedArray.any() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 3 min read
- Numpy MaskedArray.all() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays. Masked arrays are arr 3 min read
- Numpy MaskedArray.argmin() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 3 min read
- Numpy MaskedArray.argmax() function | Python In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays.Masked arrays are arra 3 min read