MCPcopy
hub / github.com/pydata/xarray / map

Method map

xarray/core/groupby.py:1796–1834  ·  view source on GitHub ↗

Apply a function to each Dataset in the group and concatenate them together into a new Dataset. `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds` in this group. Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how to st

(
        self,
        func: Callable[..., Dataset],
        args: tuple[Any, ...] = (),
        shortcut: bool | None = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1794 return FrozenMappingWarningOnValuesAccess(self._dims)
1795
1796 def map(
1797 self,
1798 func: Callable[..., Dataset],
1799 args: tuple[Any, ...] = (),
1800 shortcut: bool | None = None,
1801 **kwargs: Any,
1802 ) -> Dataset:
1803 """Apply a function to each Dataset in the group and concatenate them
1804 together into a new Dataset.
1805
1806 `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds`
1807 in this group.
1808
1809 Apply uses heuristics (like `pandas.GroupBy.apply`) to figure out how
1810 to stack together the datasets. The rule is:
1811
1812 1. If the dimension along which the group coordinate is defined is
1813 still in the first grouped item after applying `func`, then stack
1814 over this dimension.
1815 2. Otherwise, stack over the new dimension given by name of this
1816 grouping (the argument to the `groupby` function).
1817
1818 Parameters
1819 ----------
1820 func : callable
1821 Callable to apply to each sub-dataset.
1822 args : tuple, optional
1823 Positional arguments to pass to `func`.
1824 **kwargs
1825 Used to call `func(ds, **kwargs)` for each sub-dataset `ar`.
1826
1827 Returns
1828 -------
1829 applied : Dataset
1830 The result of splitting, applying and combining this dataset.
1831 """
1832 # ignore shortcut if set (for now)
1833 applied = (func(ds, *args, **kwargs) for ds in self._iter_grouped())
1834 return self._combine(applied)
1835
1836 def apply(self, func, args=(), shortcut=None, **kwargs):
1837 """

Callers 3

applyMethod · 0.95
reduceMethod · 0.95
assignMethod · 0.95

Calls 3

_combineMethod · 0.95
_iter_groupedMethod · 0.80
funcFunction · 0.50

Tested by

no test coverage detected