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

Method count

xarray/namedarray/_aggregations.py:28–77  ·  view source on GitHub ↗

Reduce this NamedArray'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 ``di

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

Source from the content-addressed store, hash-verified

26 raise NotImplementedError()
27
28 def count(
29 self,
30 dim: Dims = None,
31 **kwargs: Any,
32 ) -> Self:
33 """
34 Reduce this NamedArray's data by applying ``count`` along some dimension(s).
35
36 Parameters
37 ----------
38 dim : str, Iterable of Hashable, "..." or None, default: None
39 Name of dimension[s] along which to apply ``count``. For e.g. ``dim="x"``
40 or ``dim=["x", "y"]``. If "..." or None, will reduce over all dimensions.
41 **kwargs : Any
42 Additional keyword arguments passed on to the appropriate array
43 function for calculating ``count`` on this object's data.
44 These could include dask-specific kwargs like ``split_every``.
45
46 Returns
47 -------
48 reduced : NamedArray
49 New NamedArray with ``count`` applied to its data and the
50 indicated dimension(s) removed
51
52 See Also
53 --------
54 pandas.DataFrame.count
55 dask.dataframe.DataFrame.count
56 Dataset.count
57 DataArray.count
58 :ref:`agg`
59 User guide on reduction or aggregation operations.
60
61 Examples
62 --------
63 >>> from xarray.namedarray.core import NamedArray
64 >>> na = NamedArray("x", np.array([1, 2, 3, 0, 2, np.nan]))
65 >>> na
66 <xarray.NamedArray (x: 6)> Size: 48B
67 array([ 1., 2., 3., 0., 2., nan])
68
69 >>> na.count()
70 <xarray.NamedArray ()> Size: 8B
71 array(5)
72 """
73 return self.reduce(
74 duck_array_ops.count,
75 dim=dim,
76 **kwargs,
77 )
78
79 def all(
80 self,

Callers 3

_parse_dimensionsMethod · 0.45
infix_dimsFunction · 0.45

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected