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

Method mean

xarray/namedarray/_aggregations.py:315–378  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

313 )
314
315 def mean(
316 self,
317 dim: Dims = None,
318 *,
319 skipna: bool | None = None,
320 **kwargs: Any,
321 ) -> Self:
322 """
323 Reduce this NamedArray's data by applying ``mean`` along some dimension(s).
324
325 Parameters
326 ----------
327 dim : str, Iterable of Hashable, "..." or None, default: None
328 Name of dimension[s] along which to apply ``mean``. For e.g. ``dim="x"``
329 or ``dim=["x", "y"]``. If "..." or None, will reduce over all dimensions.
330 skipna : bool or None, optional
331 If True, skip missing values (as marked by NaN). By default, only
332 skips missing values for float dtypes; other dtypes either do not
333 have a sentinel missing value (int) or ``skipna=True`` has not been
334 implemented (object, datetime64 or timedelta64).
335 **kwargs : Any
336 Additional keyword arguments passed on to the appropriate array
337 function for calculating ``mean`` on this object's data.
338 These could include dask-specific kwargs like ``split_every``.
339
340 Returns
341 -------
342 reduced : NamedArray
343 New NamedArray with ``mean`` applied to its data and the
344 indicated dimension(s) removed
345
346 See Also
347 --------
348 numpy.mean
349 dask.array.mean
350 Dataset.mean
351 DataArray.mean
352 :ref:`agg`
353 User guide on reduction or aggregation operations.
354
355 Examples
356 --------
357 >>> from xarray.namedarray.core import NamedArray
358 >>> na = NamedArray("x", np.array([1, 2, 3, 0, 2, np.nan]))
359 >>> na
360 <xarray.NamedArray (x: 6)> Size: 48B
361 array([ 1., 2., 3., 0., 2., nan])
362
363 >>> na.mean()
364 <xarray.NamedArray ()> Size: 8B
365 array(1.6)
366
367 Use ``skipna`` to control whether NaNs are ignored.
368
369 >>> na.mean(skipna=False)
370 <xarray.NamedArray ()> Size: 8B
371 array(nan)
372 """

Callers

nothing calls this directly

Calls 1

reduceMethod · 0.95

Tested by

no test coverage detected