home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1362683132

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1362683132 I_kwDOAMm_X85ROOT8 6995 `mean` returns empty DataArray for `groupby_bins` containing `datetime64` 43613877 open 0     1 2022-09-06T04:20:40Z 2022-09-30T17:18:22Z   CONTRIBUTOR      

What happened?

Applying the mean operator to an xarray dataset that has been grouped by bins, removes variables containing values of type datetime64.

What did you expect to happen?

I expect that all variables are preserved after applying the mean-operator. For min and max this works as expected. sum is not meaningful, so it makes sense that the variable is dropped in that case as well.

Minimal Complete Verifiable Example

```Python import numpy as np import pandas as pd import xarray as xr

times = pd.date_range('2020-01-01', '2020-02-01', freq='1H') index = np.arange(len(times)) bins = np.arange(0,len(index),5) ds=xr.Dataset({'time':('index', times),'float':('index', np.linspace(0,1,len(index)))},coords={'index':index})

ds.groupby_bins('index', bins).mean() <xarray.Dataset> Dimensions: (index_bins: 148) Coordinates: * index_bins (index_bins) object (0, 5] (5, 10] ... (730, 735] (735, 740] Data variables: float (index_bins) float64 0.004032 0.01075 0.01747 ... 0.9852 0.9919

ds.groupby_bins('index', bins).min() <xarray.Dataset> Dimensions: (index_bins: 148) Coordinates: * index_bins (index_bins) object (0, 5] (5, 10] ... (730, 735] (735, 740] Data variables: time (index_bins) datetime64[ns] 2020-01-01T01:00:00 ... 2020-01-3... float (index_bins) float64 0.001344 0.008065 0.01478 ... 0.9825 0.9892 ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:43:44) [Clang 13.0.1 ] python-bits: 64 OS: Darwin OS-release: 21.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: ('en_US', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.6.0 pandas: 1.4.4 numpy: 1.23.2 scipy: None netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.5.3 cartopy: None seaborn: None numbagg: None fsspec: 2022.8.2 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.3.0 pip: 22.2.2 conda: None pytest: None IPython: 8.4.0 sphinx: None
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6995/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 1 row from issue in issue_comments
Powered by Datasette · Queries took 1.142ms · About: xarray-datasette