Reduce this DataArray'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,
)
| 6822 | raise NotImplementedError() |
| 6823 | |
| 6824 | def count( |
| 6825 | self, |
| 6826 | dim: Dims = None, |
| 6827 | *, |
| 6828 | keep_attrs: bool | None = None, |
| 6829 | **kwargs: Any, |
| 6830 | ) -> DataArray: |
| 6831 | """ |
| 6832 | Reduce this DataArray's data by applying ``count`` along some dimension(s). |
| 6833 | |
| 6834 | Parameters |
| 6835 | ---------- |
| 6836 | dim : str, Iterable of Hashable, "..." or None, default: None |
| 6837 | Name of dimension[s] along which to apply ``count``. For e.g. ``dim="x"`` |
| 6838 | or ``dim=["x", "y"]``. If None, will reduce over the GroupBy dimensions. |
| 6839 | If "...", will reduce over all dimensions. |
| 6840 | keep_attrs : bool or None, optional |
| 6841 | If True, ``attrs`` will be copied from the original |
| 6842 | object to the new one. If False, the new object will be |
| 6843 | returned without attributes. |
| 6844 | **kwargs : Any |
| 6845 | Additional keyword arguments passed on to the appropriate array |
| 6846 | function for calculating ``count`` on this object's data. |
| 6847 | These could include dask-specific kwargs like ``split_every``. |
| 6848 | |
| 6849 | Returns |
| 6850 | ------- |
| 6851 | reduced : DataArray |
| 6852 | New DataArray with ``count`` applied to its data and the |
| 6853 | indicated dimension(s) removed |
| 6854 | |
| 6855 | See Also |
| 6856 | -------- |
| 6857 | pandas.DataFrame.count |
| 6858 | dask.dataframe.DataFrame.count |
| 6859 | DataArray.count |
| 6860 | :ref:`groupby` |
| 6861 | User guide on groupby operations. |
| 6862 | |
| 6863 | Notes |
| 6864 | ----- |
| 6865 | Use the ``flox`` package to significantly speed up groupby computations, |
| 6866 | especially with dask arrays. Xarray will use flox by default if installed. |
| 6867 | Pass flox-specific keyword arguments in ``**kwargs``. |
| 6868 | See the `flox documentation <https://flox.readthedocs.io>`_ for more. |
| 6869 | |
| 6870 | Examples |
| 6871 | -------- |
| 6872 | >>> da = xr.DataArray( |
| 6873 | ... np.array([1, 2, 3, 0, 2, np.nan]), |
| 6874 | ... dims="time", |
| 6875 | ... coords=dict( |
| 6876 | ... time=("time", pd.date_range("2001-01-01", freq="ME", periods=6)), |
| 6877 | ... labels=("time", np.array(["a", "b", "c", "c", "b", "a"])), |
| 6878 | ... ), |
| 6879 | ... ) |
| 6880 | >>> da |
| 6881 | <xarray.DataArray (time: 6)> Size: 48B |
nothing calls this directly
no test coverage detected