home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 443543672

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/2587#issuecomment-443543672 https://api.github.com/repos/pydata/xarray/issues/2587 443543672 MDEyOklzc3VlQ29tbWVudDQ0MzU0MzY3Mg== 6628425 2018-12-02T21:26:50Z 2018-12-02T21:26:50Z MEMBER

Thanks for the clear report @Huite. Indeed we did not consider this particular use case when updating the behavior in version 0.11 (i.e. non-cftime dates passed to the DataArray constructor that are outside the np.datetime64[ns] range).

As you noted, in this situation it would probably make sense to coerce these dates to a cftime date type; specifically, I think the correct type to use would be cftime.DatetimeProlepticGregorian, because the Python documentation states that datetime.date (and by extension datetime.datetime) objects assume "the current Gregorian calendar always was, and always will be, in effect."

Note if you use cftime.datetime objects directly things work as you might expect: ``` In [1]: import cftime; import xarray

In [2]: times = [cftime.DatetimeProlepticGregorian(1000, 1, 1)]

In [3]: da = xarray.DataArray(times, dims=['time'], coords=[times])

In [4]: da Out[4]: <xarray.DataArray (time: 1)> array([cftime.DatetimeProlepticGregorian(1000, 1, 1, 0, 0, 0, 0, 0, 1)], dtype=object) Coordinates: * time (time) object 1000-01-01 00:00:00 ```

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