home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1230234269

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/6953#issuecomment-1230234269 https://api.github.com/repos/pydata/xarray/issues/6953 1230234269 IC_kwDOAMm_X85JU-Kd 28786187 2022-08-29T12:41:47Z 2022-08-29T12:41:47Z CONTRIBUTOR

Hi @mathause

It does work if the array keeps the size:

python data.resample(index="M").apply(lambda x: x.values)

Thanks, but I am not sure I find that intuitive, why should the resampled array have the same size as the original? It seems to make only sense for DataArray.apply(), but not for a resampled one. As I indicated in my other reply, returning a scalar or equivalent should be fine, shouldn't it? At the very least the documentation is lacking, it refers to the pandas method, but clearly the behaviour is different.

As a workaround you could allow your function to consume a dummy axis. Or you could pass dim as ...

python data.resample(index="M").reduce(lambda x, axis: 1) # workaround 1 data.resample(index="M").reduce(lambda x: 1, dim=...) # workaround 2

(reduce only passes axis if dim is not None but groupby passes the group_dim per default.

That feels a bit like curing the symptoms instead of the root cause, why not set dim='...' if it is not given?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1350803561
Powered by Datasette · Queries took 79.27ms · About: xarray-datasette