lmedian
lmedian(a, axis=None, *, ignore_inf=False, validate=True)Return the lower value-selecting median while skipping NaN values.
Parameters
a : array_like-
Input data. Supported numeric inputs are normalized to a contiguous kernel array when
validate=True. Computed reducers promote integer and bool inputs tofloat64; exact selection reducers keep integer and bool dtypes where the selected value can be returned exactly. Complex and object arrays are not supported. axis : None, 0, -1, or int = None-
Axis to reduce.
Nonereduces the whole array.0reduces strided reducing-axis slices into the remaining shape.-1andndim - 1reduce contiguous slices. Other axes raiseNotImplementedError. ignore_inf : bool = False-
If
False, skip only NaN values and keep+/-infvalues, matching NumPy’snan*reducers. IfTrue, skip all non-finite values. validate : bool = True-
If
True, check dtype, dimensionality, contiguity, and axis validity before entering the Rust kernel. IfFalse, the caller must provide a contiguous supported kernel dtype (float32,float64, bool, or a NumPy integer dtype).validate=Falseskips dtype promotion: integer and bool arrays are reduced directly, while complex and object arrays remain unsupported.
Returns
out : scalar or ndarray-
Reduction result. Float inputs return float results. Integer and bool inputs return an exact selected value for non-empty reducing-axis slices:
axis=Nonereturns a Python scalar and axis reductions preserve the input dtype.
Notes
For an even number of retained values, lmedian returns the lower of the two middle values instead of averaging them. For an odd number of retained values it matches median.
NaN-aware reducers skip NaN values directly, without building a filtered copy of the input.
For integer and bool arrays there is no NaN to skip, so the nan* forms return the same result as their plain counterparts. min, nanmin, max, nanmax, and lmedian preserve the integer or bool dtype for non-empty reducing-axis slices.