blosc2.mean#

blosc2.mean(ndarr: NDArray | NDField | C2Array | LazyExpr, axis: int | tuple[int] = None, dtype: dtype = None, keepdims: bool = False, **kwargs: dict) ndarray | NDArray | int | float | complex | bool#

Return the arithmetic mean along the specified axis.

Parameters:
  • ndarr (NDArray or NDField or C2Array or LazyExpr) – The input array or expression.

  • axis (int or tuple of ints, optional) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

  • dtype (np.dtype, optional) – Type to use in computing the mean. For integer inputs, the default is float32; for floating point inputs, it is the same as the input dtype.

  • keepdims (bool, optional) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

  • kwargs (dict, optional) – Keyword arguments that are supported by the empty() constructor.

Returns:

mean_along_axis – The mean of the elements along the axis.

Return type:

np.ndarray or NDArray or scalar

References

np.mean

Examples

>>> import numpy as np
>>> import blosc2
>>> # Example array
>>> array = np.array([[1, 2, 3], [4, 5, 6]]
>>> nd_array = blosc2.asarray(array)
>>> # Compute the mean of all elements in the array (axis=None)
>>> overall_mean = blosc2.mean(nd_array)
>>> print("Mean of all elements:", overall_mean)
Mean of all elements: 3.5