home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 110726841

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
110726841 MDU6SXNzdWUxMTA3MjY4NDE= 615 operations with pd.to_timedelta() now fails 291576 closed 0     3 2015-10-09T20:01:00Z 2015-10-09T21:21:41Z 2015-10-09T20:15:49Z CONTRIBUTOR      

Not exactly sure when this started to fail, but I recently upgraded my pandas install and a script of mine started to fail. The SSCCE:

``` from datetime import datetime, timedelta import xray import pandas as pd

a = xray.Dataset({'time': [datetime(2000, 1, 1)]}) a['time'] -= pd.to_timedelta(timedelta(hours=6)) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/nas/home/broot/centos6/lib/python2.7/site-packages/xray-0.6.0_154_gf270b9f-py2.7.egg/xray/core/dataarray.py", line 1091, in func f(self.variable, other_variable) File "/nas/home/broot/centos6/lib/python2.7/site-packages/xray-0.6.0_154_gf270b9f-py2.7.egg/xray/core/variable.py", line 799, in func self.values = f(self_data, other_data) TypeError: ufunc subtract cannot use operands with types dtype('<M8[ns]') and dtype('O') ```

Perhaps it makes sense to create a new xray convenience method like pandas's "to_timedelta()" that returns numpy arrays of timedelta64 instead of pandas's special timedelta objects? Or to somehow cast these objects appropriately on the fly?

My current workaround is the following:

import numpy as np a['time'] -= np.array([6], dtype='timedelta64[h]')

While that particular form isn't terrible, it gets very awkward if my timedelta is a combination of different units like 3 hours and 15 minutes or something odd like that.

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

Links from other tables

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