Reduce this array by applying `func` along some dimension(s). Parameters ---------- func : callable Function which can be called in the form `f(x, axis=axis, **kwargs)` to return the result of reducing an np.ndarray over an integer valued
(
self,
func: Callable[..., Any],
dim: Dims = None,
*,
axis: int | Sequence[int] | None = None,
keep_attrs: bool | None = None,
keepdims: bool = False,
**kwargs: Any,
)
| 3869 | return ops.fillna(self, other, join="outer") |
| 3870 | |
| 3871 | def reduce( |
| 3872 | self, |
| 3873 | func: Callable[..., Any], |
| 3874 | dim: Dims = None, |
| 3875 | *, |
| 3876 | axis: int | Sequence[int] | None = None, |
| 3877 | keep_attrs: bool | None = None, |
| 3878 | keepdims: bool = False, |
| 3879 | **kwargs: Any, |
| 3880 | ) -> Self: |
| 3881 | """Reduce this array by applying `func` along some dimension(s). |
| 3882 | |
| 3883 | Parameters |
| 3884 | ---------- |
| 3885 | func : callable |
| 3886 | Function which can be called in the form |
| 3887 | `f(x, axis=axis, **kwargs)` to return the result of reducing an |
| 3888 | np.ndarray over an integer valued axis. |
| 3889 | dim : "...", str, Iterable of Hashable or None, optional |
| 3890 | Dimension(s) over which to apply `func`. By default `func` is |
| 3891 | applied over all dimensions. |
| 3892 | axis : int or sequence of int, optional |
| 3893 | Axis(es) over which to repeatedly apply `func`. Only one of the |
| 3894 | 'dim' and 'axis' arguments can be supplied. If neither are |
| 3895 | supplied, then the reduction is calculated over the flattened array |
| 3896 | (by calling `f(x)` without an axis argument). |
| 3897 | keep_attrs : bool or None, optional |
| 3898 | If True (default), the variable's attributes (`attrs`) will be copied from |
| 3899 | the original object to the new one. If False, the new |
| 3900 | object will be returned without attributes. |
| 3901 | keepdims : bool, default: False |
| 3902 | If True, the dimensions which are reduced are left in the result |
| 3903 | as dimensions of size one. Coordinates that use these dimensions |
| 3904 | are removed. |
| 3905 | **kwargs : dict |
| 3906 | Additional keyword arguments passed on to `func`. |
| 3907 | |
| 3908 | Returns |
| 3909 | ------- |
| 3910 | reduced : DataArray |
| 3911 | DataArray with this object's array replaced with an array with |
| 3912 | summarized data and the indicated dimension(s) removed. |
| 3913 | """ |
| 3914 | |
| 3915 | var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs) |
| 3916 | return self._replace_maybe_drop_dims(var) |
| 3917 | |
| 3918 | def to_pandas(self) -> Self | pd.Series | pd.DataFrame: |
| 3919 | """Convert this array into a pandas object with the same shape. |