You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -120,7 +120,7 @@ More formally, `indexes` would accept `Mapping[CoordinateNames, IndexSpec]` wher
120
120
Currently index objects like `pandas.MultiIndex` can be passed directly to `coords`, which in this specific case results in the implicit creation of virtual coordinates. With the new `indexes` argument this behavior may become even more confusing than it currently is. For the sake of clarity, it would be appropriate to eventually drop support for this specific behavior and treat any given mapping value given in `coords` as an array that can be wrapped into an Xarray variable, i.e., in the case of a multi-index:
>>> da = xr.DataArray([1.0, 2.0], dims="x", coords={"x": midx})
174
174
>>> da
175
175
<xarray.DataArray (x: 2)>
176
176
array([1., 2.])
@@ -201,7 +201,9 @@ Besides `pandas.MultiIndex`, there may be other situations where we would like t
201
201
The example given here is quite confusing, though: this is not an easily predictable behavior. We could entirely avoid the implicit creation of coordinates, e.g., using a helper function that generates coordinate + index dictionaries that we could then pass directly to the DataArray/Dataset constructor:
# subset = ds.where(ds.x == element, drop=True) # alternative
30
-
result = subset.mean() # apply
30
+
result = subset.mean() # apply
31
31
results.append(result)
32
32
33
33
xr.concat(results) # combine
@@ -36,7 +36,7 @@ xr.concat(results) # combine
36
36
to
37
37
38
38
```python
39
-
ds.groupby('x').mean() # splits, applies, and combines
39
+
ds.groupby("x").mean() # splits, applies, and combines
40
40
```
41
41
42
42
Efficient vectorized implementations of this pattern are implemented in numpy's [`ufunc.at`](https://numpy.org/doc/stable/reference/generated/numpy.ufunc.at.html), [`ufunc.reduceat`](https://numpy.org/doc/stable/reference/generated/numpy.ufunc.reduceat.html), [`numbagg.grouped`](https://github.com/numbagg/numbagg/blob/main/numbagg/grouped.py), [`numpy_groupies`](https://github.com/ml31415/numpy-groupies), and probably more.
@@ -110,11 +110,13 @@ All Grouper objects will subclass from a Grouper object
0 commit comments