MCPcopy Create free account
hub / github.com/pydata/xarray / median

Method median

xarray/core/_aggregations.py:7906–7998  ·  view source on GitHub ↗

Reduce this DataArray'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 ``d

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

Source from the content-addressed store, hash-verified

7904 return out
7905
7906 def median(
7907 self,
7908 dim: Dims = None,
7909 *,
7910 skipna: bool | None = None,
7911 keep_attrs: bool | None = None,
7912 **kwargs: Any,
7913 ) -> DataArray:
7914 """
7915 Reduce this DataArray's data by applying ``median`` along some dimension(s).
7916
7917 Parameters
7918 ----------
7919 dim : str, Iterable of Hashable, "..." or None, default: None
7920 Name of dimension[s] along which to apply ``median``. For e.g. ``dim="x"``
7921 or ``dim=["x", "y"]``. If None, will reduce over the GroupBy dimensions.
7922 If "...", will reduce over all dimensions.
7923 skipna : bool or None, optional
7924 If True, skip missing values (as marked by NaN). By default, only
7925 skips missing values for float dtypes; other dtypes either do not
7926 have a sentinel missing value (int) or ``skipna=True`` has not been
7927 implemented (object, datetime64 or timedelta64).
7928 keep_attrs : bool or None, optional
7929 If True, ``attrs`` will be copied from the original
7930 object to the new one. If False, the new object will be
7931 returned without attributes.
7932 **kwargs : Any
7933 Additional keyword arguments passed on to the appropriate array
7934 function for calculating ``median`` on this object's data.
7935 These could include dask-specific kwargs like ``split_every``.
7936
7937 Returns
7938 -------
7939 reduced : DataArray
7940 New DataArray with ``median`` applied to its data and the
7941 indicated dimension(s) removed
7942
7943 See Also
7944 --------
7945 numpy.median
7946 dask.array.median
7947 DataArray.median
7948 :ref:`groupby`
7949 User guide on groupby operations.
7950
7951 Notes
7952 -----
7953 Use the ``flox`` package to significantly speed up groupby computations,
7954 especially with dask arrays. Xarray will use flox by default if installed.
7955 Pass flox-specific keyword arguments in ``**kwargs``.
7956 See the `flox documentation <https://flox.readthedocs.io>`_ for more.
7957
7958 Non-numeric variables will be removed prior to reducing.
7959
7960 Examples
7961 --------
7962 >>> da = xr.DataArray(
7963 ... np.array([1, 2, 3, 0, 2, np.nan]),

Callers

nothing calls this directly

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected