home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 341614052

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/364#issuecomment-341614052 https://api.github.com/repos/pydata/xarray/issues/364 341614052 MDEyOklzc3VlQ29tbWVudDM0MTYxNDA1Mg== 1217238 2017-11-03T03:13:14Z 2017-11-03T03:13:14Z MEMBER

Have you tried iterating over a resample object in the v0.10 release candidate? I believe the new resample API supports iteration. On Thu, Nov 2, 2017 at 5:40 PM hazbottles notifications@github.com wrote:

Hi, being able to pass a pd.TimeGrouper to .groupby() would be really handy. Here is my use-case and work around at the moment (.resample() doesn't serve my needs because I need to iterate over the groups:

import pandas as pdimport xarray as xr

dates = pd.DatetimeIndex(['2017-01-01 15:00', '2017-01-02 14:00', '2017-01-02 23:00']) da = xr.DataArray([1, 2, 3], dims=['time'], coords={'time': dates}) time_grouper = pd.TimeGrouper(freq='24h', base=15)

digging around the source code for xr.DataArray.resample i found this

grouped = xr.core.groupby.DataArrayGroupBy(da, 'time', grouper=time_grouper) for _, sub_da in grouped: print(sub_da)

which prints:

<xarray.DataArray (time: 2)> array([1, 2]) Coordinates: * time (time) datetime64[ns] 2017-01-01T15:00:00 2017-01-02T14:00:00 <xarray.DataArray (time: 1)> array([3]) Coordinates: * time (time) datetime64[ns] 2017-01-02T23:00:00

Would it be possible to add a grouper kwarg to .groupby(), e.g.

da.groupby('time', grouper=time_grouper)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pydata/xarray/issues/364#issuecomment-341598412, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKS1sv9n8gxYr6Dne83Hfp0IJl_5gMvks5symDugaJpZM4DredK .

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