dask 2021.10.0

NotesParametersReturns
nanmedian(a, axis=None, keepdims=False, out=None)

This docstring was copied from numpy.nanmedian.

Some inconsistencies with the Dask version may exist.

This works by automatically chunking the reduced axes to a single chunk and then calling numpy.nanmedian function across the remaining dimensions

Returns the median of the array elements.

versionadded

Notes

Given a vector V of length N , the median of V is the middle value of a sorted copy of V , V_sorted - i.e., V_sorted[(N-1)/2] , when N is odd and the average of the two middle values of V_sorted when N is even.

Parameters

a : array_like

Input array or object that can be converted to an array.

axis : {int, sequence of int, None}, optional

Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the array. A sequence of axes is supported since version 1.9.0.

out : ndarray, optional

Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary.

overwrite_input : bool, optional (Not supported in Dask)

If True, then allow use of memory of input array a for calculations. The input array will be modified by the call to median . This will save memory when you do not need to preserve the contents of the input array. Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. If :None:None:`overwrite_input` is True and a is not already an :None:None:`ndarray`, an error will be raised.

keepdims : bool, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

If this is anything but the default value it will be passed through (in the special case of an empty array) to the mean function of the underlying array. If the array is a sub-class and mean does not have the kwarg keepdims this will raise a RuntimeError.

Returns

median : ndarray

A new array holding the result. If the input contains integers or floats smaller than float64 , then the output data-type is np.float64 . Otherwise, the data-type of the output is the same as that of the input. If :None:None:`out` is specified, that array is returned instead.

Compute the median along the specified axis, while ignoring NaNs.

See Also

mean
median
percentile

Examples

This example is valid syntax, but we were not able to check execution
>>> a = np.array([[10.0, 7, 4], [3, 2, 1]])  # doctest: +SKIP
... a[0, 1] = np.nan # doctest: +SKIP
... a # doctest: +SKIP array([[10., nan, 4.], [ 3., 2., 1.]])
This example is valid syntax, but we were not able to check execution
>>> np.median(a)  # doctest: +SKIP
nan
This example is valid syntax, but we were not able to check execution
>>> np.nanmedian(a)  # doctest: +SKIP
3.0
This example is valid syntax, but we were not able to check execution
>>> np.nanmedian(a, axis=0)  # doctest: +SKIP
array([6.5, 2. , 2.5])
This example is valid syntax, but we were not able to check execution
>>> np.median(a, axis=1)  # doctest: +SKIP
array([nan,  2.])
This example is valid syntax, but we were not able to check execution
>>> b = a.copy()  # doctest: +SKIP
... np.nanmedian(b, axis=1, overwrite_input=True) # doctest: +SKIP array([7., 2.])
This example is valid syntax, but we were not able to check execution
>>> assert not np.all(a==b)  # doctest: +SKIP
... b = a.copy() # doctest: +SKIP
... np.nanmedian(b, axis=None, overwrite_input=True) # doctest: +SKIP 3.0
This example is valid syntax, but we were not able to check execution
>>> assert not np.all(a==b)  # doctest: +SKIP
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/reductions.py#1635
type: <class 'function'>
Commit: