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

Method count

xarray/core/_aggregations.py:5280–5375  ·  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

5278 raise NotImplementedError()
5279
5280 def count(
5281 self,
5282 dim: Dims = None,
5283 *,
5284 keep_attrs: bool | None = None,
5285 **kwargs: Any,
5286 ) -> Dataset:
5287 """
5288 Reduce this Dataset's data by applying ``count`` along some dimension(s).
5289
5290 Parameters
5291 ----------
5292 dim : str, Iterable of Hashable, "..." or None, default: None
5293 Name of dimension[s] along which to apply ``count``. For e.g. ``dim="x"``
5294 or ``dim=["x", "y"]``. If None, will reduce over the Resample dimensions.
5295 If "...", will reduce over all dimensions.
5296 keep_attrs : bool or None, optional
5297 If True, ``attrs`` will be copied from the original
5298 object to the new one. If False, the new object will be
5299 returned without attributes.
5300 **kwargs : Any
5301 Additional keyword arguments passed on to the appropriate array
5302 function for calculating ``count`` on this object's data.
5303 These could include dask-specific kwargs like ``split_every``.
5304
5305 Returns
5306 -------
5307 reduced : Dataset
5308 New Dataset with ``count`` applied to its data and the
5309 indicated dimension(s) removed
5310
5311 See Also
5312 --------
5313 pandas.DataFrame.count
5314 dask.dataframe.DataFrame.count
5315 Dataset.count
5316 :ref:`resampling`
5317 User guide on resampling operations.
5318
5319 Notes
5320 -----
5321 Use the ``flox`` package to significantly speed up resampling computations,
5322 especially with dask arrays. Xarray will use flox by default if installed.
5323 Pass flox-specific keyword arguments in ``**kwargs``.
5324 See the `flox documentation <https://flox.readthedocs.io>`_ for more.
5325
5326 Examples
5327 --------
5328 >>> da = xr.DataArray(
5329 ... np.array([1, 2, 3, 0, 2, np.nan]),
5330 ... dims="time",
5331 ... coords=dict(
5332 ... time=("time", pd.date_range("2001-01-01", freq="ME", periods=6)),
5333 ... labels=("time", np.array(["a", "b", "c", "c", "b", "a"])),
5334 ... ),
5335 ... )
5336 >>> ds = xr.Dataset(dict(da=da))
5337 >>> ds

Callers

nothing calls this directly

Calls 3

_flox_reduceMethod · 0.95
reduceMethod · 0.95

Tested by

no test coverage detected