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

Method count

xarray/core/_aggregations.py:3736–3831  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

3734 raise NotImplementedError()
3735
3736 def count(
3737 self,
3738 dim: Dims = None,
3739 *,
3740 keep_attrs: bool | None = None,
3741 **kwargs: Any,
3742 ) -> Dataset:
3743 """
3744 Reduce this Dataset's data by applying ``count`` along some dimension(s).
3745
3746 Parameters
3747 ----------
3748 dim : str, Iterable of Hashable, "..." or None, default: None
3749 Name of dimension[s] along which to apply ``count``. For e.g. ``dim="x"``
3750 or ``dim=["x", "y"]``. If None, will reduce over the GroupBy dimensions.
3751 If "...", will reduce over all dimensions.
3752 keep_attrs : bool or None, optional
3753 If True, ``attrs`` will be copied from the original
3754 object to the new one. If False, the new object will be
3755 returned without attributes.
3756 **kwargs : Any
3757 Additional keyword arguments passed on to the appropriate array
3758 function for calculating ``count`` on this object's data.
3759 These could include dask-specific kwargs like ``split_every``.
3760
3761 Returns
3762 -------
3763 reduced : Dataset
3764 New Dataset with ``count`` applied to its data and the
3765 indicated dimension(s) removed
3766
3767 See Also
3768 --------
3769 pandas.DataFrame.count
3770 dask.dataframe.DataFrame.count
3771 Dataset.count
3772 :ref:`groupby`
3773 User guide on groupby operations.
3774
3775 Notes
3776 -----
3777 Use the ``flox`` package to significantly speed up groupby computations,
3778 especially with dask arrays. Xarray will use flox by default if installed.
3779 Pass flox-specific keyword arguments in ``**kwargs``.
3780 See the `flox documentation <https://flox.readthedocs.io>`_ for more.
3781
3782 Examples
3783 --------
3784 >>> da = xr.DataArray(
3785 ... np.array([1, 2, 3, 0, 2, np.nan]),
3786 ... dims="time",
3787 ... coords=dict(
3788 ... time=("time", pd.date_range("2001-01-01", freq="ME", periods=6)),
3789 ... labels=("time", np.array(["a", "b", "c", "c", "b", "a"])),
3790 ... ),
3791 ... )
3792 >>> ds = xr.Dataset(dict(da=da))
3793 >>> ds

Callers

nothing calls this directly

Calls 3

_flox_reduceMethod · 0.95
reduceMethod · 0.95

Tested by

no test coverage detected