Repository navigation
Replies: 3 comments 1 reply
|
Do you remember the function you used? E.g. the following works air = xr.tutorial.load_dataset("air_temperature")
air.map(lambda x: 1) |
|
@keewis is correct, this is using the result of |
|
Yes, for import xarray as xr
a = xr.DataArray([1, 3, 2, 8], dims="sample",
coords={"group": ("sample", ["a", "a", "b", "b"])})
a.groupby("group").map(lambda g: xr.DataArray(int(g.max())))
# dims: ('group',), values: [3, 8]The same function with just |
Uh oh!
There was an error while loading. Please reload this page.
The user documentation doesn't really give much information on what kind of functions you can use with
map(), it seems like it only covers numpy ufuncs or compositions of them. The example of using a custom function is:which will return a
DataArrayforDataArrayinput. The documentation doesn't explicitly state that this is required, but when I try to use it with a function that returns a scalar I get:Wrapping the return value in a zero-dimensional
DataArrayfixes the issue. Is this the expected behavior?All reactions