issues: 181534708
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
181534708 | MDU6SXNzdWUxODE1MzQ3MDg= | 1041 | DataArray resample does not work if the time coordinate name is different from the corresponding dimension name. | 900941 | closed | 0 | 11 | 2016-10-06T21:49:47Z | 2020-01-24T03:02:16Z | 2020-01-24T03:02:16Z | CONTRIBUTOR | Please see the example below and the output it produces. And the exception is not really helpful... ``` python from xarray import DataArray from datetime import datetime, timedelta def main(): N = 48 data = range(N)
# Create DataArray objects using the above defined schemes a1 = DataArray.from_dict(scheme1) print(a1) print(a1.resample("D", "t")) print("=======================")
if name == 'main': main() ``` Below is the output I get from running the script: ``` <xarray.DataArray (t: 48)> array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) Coordinates: * t (t) datetime64[ns] 2001-01-01 2001-01-01T01:00:00 ... <xarray.DataArray (t: 2)> array([ 11.5, 35.5]) Coordinates: * t (t) datetime64[ns] 2001-01-01 2001-01-02 ======================= <xarray.DataArray (t: 48)> array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) Coordinates: time (t) datetime64[ns] 2001-01-01 2001-01-01T01:00:00 ... * t (t) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... Traceback (most recent call last): File "/Users/huziy/skynet2/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Python/RPN/src/demo/xarray/time_dim_and_ops.py", line 46, in <module> main() File "/Users/huziy/skynet2/RESCUE/skynet3_rech1/huziy/Netbeans Projects/Python/RPN/src/demo/xarray/time_dim_and_ops.py", line 38, in main print(a2.resample("D", "t")) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/xarray/core/common.py", line 499, in resample gb = self.groupby_cls(self, group, grouper=time_grouper) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/xarray/core/groupby.py", line 202, in init first_items = s.groupby(grouper).first() File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/core/generic.py", line 3974, in groupby kwargs) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/core/groupby.py", line 1501, in groupby return klass(obj, by, kwds) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/core/groupby.py", line 370, in init mutated=self.mutated) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/core/groupby.py", line 2403, in _get_grouper binner, grouper, obj = key._get_grouper(obj) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/tseries/resample.py", line 1061, in _get_grouper r = self._get_resampler(obj) File "/Users/huziy/virtualenvs/py3.4/lib/python3.4/site-packages/pandas/tseries/resample.py", line 1057, in _get_resampler "but got an instance of %r" % type(ax).name) TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index' ``` |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/1041/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |