home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1970215879

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
1970215879 PR_kwDOAMm_X85eOCcn 8393 Port fix from pandas-dev/pandas#55283 to cftime resample 6628425 closed 0     1 2023-10-31T11:12:09Z 2023-11-02T09:40:46Z 2023-11-02T04:12:51Z MEMBER   0 pydata/xarray/pulls/8393

The remaining failing cftime resample tests in https://github.com/pydata/xarray/issues/8091 happen to be related to a bug that was fixed in the pandas implementation, https://github.com/pandas-dev/pandas/pull/55283, leading answers to change in some circumstances. This PR ports that bug fix to xarray's implementation of resample for data indexed by a CFTimeIndex.

  • [x] Fixes remaining failing cftime resample tests in https://github.com/pydata/xarray/issues/8091
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst

A simple example where answers change in pandas is the following:

Previously

```

import numpy as np; import pandas as pd index = pd.date_range("2000", periods=5, freq="5D") series = pd.Series(np.arange(index.size), index=index) series.resample("2D", closed="right", label="right", offset="1s").mean() 2000-01-01 00:00:01 0.0 2000-01-03 00:00:01 NaN 2000-01-05 00:00:01 1.0 2000-01-07 00:00:01 NaN 2000-01-09 00:00:01 NaN 2000-01-11 00:00:01 2.0 2000-01-13 00:00:01 NaN 2000-01-15 00:00:01 3.0 2000-01-17 00:00:01 NaN 2000-01-19 00:00:01 NaN 2000-01-21 00:00:01 4.0 Freq: 2D, dtype: float64 ```

Currently

```

import numpy as np; import pandas as pd index = pd.date_range("2000", periods=5, freq="5D") series = pd.Series(np.arange(index.size), index=index) series.resample("2D", closed="right", label="right", offset="1s").mean() 2000-01-01 00:00:01 0.0 2000-01-03 00:00:01 NaN 2000-01-05 00:00:01 NaN 2000-01-07 00:00:01 1.0 2000-01-09 00:00:01 NaN 2000-01-11 00:00:01 2.0 2000-01-13 00:00:01 NaN 2000-01-15 00:00:01 NaN 2000-01-17 00:00:01 3.0 2000-01-19 00:00:01 NaN 2000-01-21 00:00:01 4.0 Freq: 2D, dtype: float64 ```

This PR allows us to reproduce this change in xarray for data indexed by a CFTimeIndex. The bin edges were incorrect in the previous case; see https://github.com/pandas-dev/pandas/pull/52064#issuecomment-1785893752 for @MarcoGorelli's nice explanation as to why.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/8393/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 pull

Links from other tables

  • 3 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 1.315ms · About: xarray-datasette