MCPcopy Index your code
hub / github.com/pydata/xarray / median

Method median

xarray/namedarray/_aggregations.py:706–773  ·  view source on GitHub ↗

Reduce this NamedArray's data by applying ``median`` along some dimension(s). Parameters ---------- dim : str, Iterable of Hashable, "..." or None, default: None Name of dimension[s] along which to apply ``median``. For e.g. ``dim="x"`` or ``

(
        self,
        dim: Dims = None,
        *,
        skipna: bool | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

704 )
705
706 def median(
707 self,
708 dim: Dims = None,
709 *,
710 skipna: bool | None = None,
711 **kwargs: Any,
712 ) -> Self:
713 """
714 Reduce this NamedArray's data by applying ``median`` along some dimension(s).
715
716 Parameters
717 ----------
718 dim : str, Iterable of Hashable, "..." or None, default: None
719 Name of dimension[s] along which to apply ``median``. For e.g. ``dim="x"``
720 or ``dim=["x", "y"]``. If "..." or None, will reduce over all dimensions.
721 skipna : bool or None, optional
722 If True, skip missing values (as marked by NaN). By default, only
723 skips missing values for float dtypes; other dtypes either do not
724 have a sentinel missing value (int) or ``skipna=True`` has not been
725 implemented (object, datetime64 or timedelta64).
726 **kwargs : Any
727 Additional keyword arguments passed on to the appropriate array
728 function for calculating ``median`` on this object's data.
729 These could include dask-specific kwargs like ``split_every``.
730
731 Returns
732 -------
733 reduced : NamedArray
734 New NamedArray with ``median`` applied to its data and the
735 indicated dimension(s) removed
736
737 See Also
738 --------
739 numpy.median
740 dask.array.median
741 Dataset.median
742 DataArray.median
743 :ref:`agg`
744 User guide on reduction or aggregation operations.
745
746 Notes
747 -----
748 Non-numeric variables will be removed prior to reducing.
749
750 Examples
751 --------
752 >>> from xarray.namedarray.core import NamedArray
753 >>> na = NamedArray("x", np.array([1, 2, 3, 0, 2, np.nan]))
754 >>> na
755 <xarray.NamedArray (x: 6)> Size: 48B
756 array([ 1., 2., 3., 0., 2., nan])
757
758 >>> na.median()
759 <xarray.NamedArray ()> Size: 8B
760 array(2.)
761
762 Use ``skipna`` to control whether NaNs are ignored.
763

Callers

nothing calls this directly

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected