home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 564704057

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/3609#issuecomment-564704057 https://api.github.com/repos/pydata/xarray/issues/3609 564704057 MDEyOklzc3VlQ29tbWVudDU2NDcwNDA1Nw== 13301940 2019-12-11T19:49:18Z 2019-12-11T19:51:12Z MEMBER

1) Per Pandas documentation, the following are the defined attributes for Timedelta:

asm8 | Return a numpy timedelta64 array scalar view. -- | -- components | Return a components namedtuple-like. days | Number of days. delta | Return the timedelta in nanoseconds (ns), for internal compatibility. microseconds | Number of microseconds (>= 0 and less than 1 second). nanoseconds | Return the number of nanoseconds (n), where 0 <= n < 1 microsecond. resolution | Return a string representing the lowest timedelta resolution. resolution_string | Return a string representing the lowest timedelta resolution. seconds | Number of seconds (>= 0 and less than 1 day).

and since xarray coerces the dataarray to a Pandas Series prior accessing the requested attribute, calling start_t.dt.second fails.

2) Since seconds is a defined attribute for pandas.TimeDelta, I expect start_t.dt.seconds to work. However, it fails:

```python In [33]: start_t.dt.seconds


AttributeError Traceback (most recent call last) <ipython-input-33-e1e0943720f8> in <module> ----> 1 start_t.dt.seconds

AttributeError: 'DatetimeAccessor' object has no attribute 'seconds' ``` This is likely a bug in xarray.

3) Pandas appears to be establishing differences between DatetimeProperties and TimedeltaProperties:

```python In [16]: start_t_series.dt Out[16]: <pandas.core.indexes.accessors.TimedeltaProperties object at 0x7f2afafd45c0>

In [17]: dt_array_series.dt Out[17]: <pandas.core.indexes.accessors.DatetimeProperties object at 0x7f2bf7ccd320> ```

Xarray, on the other hand, seems to be treating them the same:

```python In [18]: dt_array.dt Out[18]: <xarray.core.accessor_dt.DatetimeAccessor at 0x7f2afb6e8710>

In [19]: start_t.dt Out[19]: <xarray.core.accessor_dt.DatetimeAccessor at 0x7f2afb6a20f0> ```

  • Should xarray establish differences between DatetimeProperties and TimedeltaProperties??
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  535812301
Powered by Datasette · Queries took 0.922ms · About: xarray-datasette