pull_requests: 378642119
This data as json
id | node_id | number | state | locked | title | user | body | created_at | updated_at | closed_at | merged_at | merge_commit_sha | assignee | milestone | draft | head | base | author_association | auto_merge | repo | url | merged_by |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
378642119 | MDExOlB1bGxSZXF1ZXN0Mzc4NjQyMTE5 | 3792 | closed | 0 | Enable pandas-style rounding of cftime.datetime objects | 6628425 | <!-- Feel free to remove check-list items aren't relevant to your change --> - [x] Tests added - [x] Passes `isort -rc . && black . && mypy . && flake8` - [x] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API This is particularly useful for removing microsecond noise that can sometimes be added from decoding times via `cftime.num2date`, though also applies more generally. The methods used here for rounding dates in the integer domain are copied from pandas. On a somewhat more internal note, this adds an `asi8` property to `CFTimeIndex`, which encodes the dates as integer values representing microseconds since 1970-01-01; this encoding is made exact via the `exact_cftime_datetime_difference` function. It's possible this could be useful in other contexts. Some examples: ``` In [1]: import xarray as xr In [2]: times = xr.cftime_range("2000", periods=5, freq="17D") In [3]: time = xr.DataArray(times, dims=["time"], name="time") In [4]: time.dt.floor("11D") Out[4]: <xarray.DataArray 'floor' (time: 5)> array([cftime.DatetimeGregorian(1999-12-31 00:00:00), cftime.DatetimeGregorian(2000-01-11 00:00:00), cftime.DatetimeGregorian(2000-02-02 00:00:00), cftime.DatetimeGregorian(2000-02-13 00:00:00), cftime.DatetimeGregorian(2000-03-06 00:00:00)], dtype=object) Coordinates: * time (time) object 2000-01-01 00:00:00 ... 2000-03-09 00:00:00 In [5]: time.dt.ceil("11D") Out[5]: <xarray.DataArray 'ceil' (time: 5)> array([cftime.DatetimeGregorian(2000-01-11 00:00:00), cftime.DatetimeGregorian(2000-01-22 00:00:00), cftime.DatetimeGregorian(2000-02-13 00:00:00), cftime.DatetimeGregorian(2000-02-24 00:00:00), cftime.DatetimeGregorian(2000-03-17 00:00:00)], dtype=object) Coordinates: * time (time) object 2000-01-01 00:00:00 ... 2000-03-09 00:00:00 In [6]: time.dt.round("11D") Out[6]: <xarray.DataArray 'round' (time: 5)> array([cftime.DatetimeGregorian(1999-12-31 00:00:00), cftime.DatetimeGregorian(2000-01-22 00:00:00), cftime.DatetimeGregorian(2000-02-02 00:00:00), cftime.DatetimeGregorian(2000-02-24 00:00:00), cftime.DatetimeGregorian(2000-03-06 00:00:00)], dtype=object) Coordinates: * time (time) object 2000-01-01 00:00:00 ... 2000-03-09 00:00:00 ``` | 2020-02-22T23:26:50Z | 2020-03-02T12:03:47Z | 2020-03-02T09:41:20Z | 2020-03-02T09:41:20Z | 45d88fc4b2524ecb0c1236cd31767d00f72b0ea1 | 0 | bc28dd21d3f94cd2a357e5848af6bc79ded3f6c0 | 20e6236f250d1507d22daf06d38b283a83c12e44 | MEMBER | 13221727 | https://github.com/pydata/xarray/pull/3792 |
Links from other tables
- 0 rows from pull_requests_id in labels_pull_requests