home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

3 rows where issue = 290023410 and user = 6628425 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 1

  • spencerkclark · 3 ✖

issue 1

  • How to broadcast along dayofyear · 3 ✖

author_association 1

  • MEMBER 3
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
418191318 https://github.com/pydata/xarray/issues/1844#issuecomment-418191318 https://api.github.com/repos/pydata/xarray/issues/1844 MDEyOklzc3VlQ29tbWVudDQxODE5MTMxOA== spencerkclark 6628425 2018-09-03T20:51:37Z 2018-09-03T20:55:08Z MEMBER

Building on the above example, if you're OK with using a coordinate of strings, the following might be a little simpler way of defining the labels to use for grouping (this is perhaps closer to a single attribute solution): ``` In [14]: month_day_str = xr.DataArray(da.indexes['time'].strftime('%m-%d'), coords=da.coords, ...: name='month_day_str') ...:

In [15]: da.groupby(month_day_str).mean('time') Out[15]: <xarray.DataArray (month_day_str: 2)> array([2., 3.]) Coordinates: * month_day_str (month_day_str) object '01-01' '03-01' ``` Note #2090 / #2144 would make this more straightforward.

{
    "total_count": 3,
    "+1": 3,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  How to broadcast along dayofyear 290023410
418188977 https://github.com/pydata/xarray/issues/1844#issuecomment-418188977 https://api.github.com/repos/pydata/xarray/issues/1844 MDEyOklzc3VlQ29tbWVudDQxODE4ODk3Nw== spencerkclark 6628425 2018-09-03T20:30:45Z 2018-09-03T20:30:45Z MEMBER

No worries @chiaral; I agree on the xarray side this isn't so well documented (you have to follow the link to the pandas description of the datetime components).

Unfortunately there is not a simple attribute for grouping by matching month and day. It is possible to define your own vector of integers for this purpose, however. Perhaps you've already found a workaround, but just in case, here is one way to define a "modified ordinal day" that you can use in a groupby call: ``` In [1]: import xarray as xr

In [2]: from datetime import datetime

In [3]: dates = [datetime(1999, 1, 1), datetime(1999, 3, 1), ...: datetime(2000, 1, 1), datetime(2000, 3, 1)] ...:

In [4]: da = xr.DataArray([1, 2, 3, 4], coords=[dates], dims=['time'])

In [5]: not_leap_year = xr.DataArray(~da.indexes['time'].is_leap_year, coords=da.coords)

In [6]: march_or_later = da.time.dt.month >= 3

In [7]: ordinal_day = da.time.dt.dayofyear

In [8]: modified_ordinal_day = ordinal_day + (not_leap_year & march_or_later)

In [9]: modified_ordinal_day = modified_ordinal_day.rename('modified_ordinal_day')

In [10]: modified_ordinal_day Out[10]: <xarray.DataArray 'modified_ordinal_day' (time: 4)> array([ 1, 61, 1, 61]) Coordinates: * time (time) datetime64[ns] 1999-01-01 1999-03-01 2000-01-01 2000-03-01

In [11]: da.groupby(modified_ordinal_day).mean('time') Out[11]: <xarray.DataArray (modified_ordinal_day: 2)> array([2., 3.]) Coordinates: * modified_ordinal_day (modified_ordinal_day) int64 1 61 Note if we use the standard ordinal day we get three groups, because of the difference between non-leap and leap years: In [12]: ordinal_day Out[12]: <xarray.DataArray 'dayofyear' (time: 4)> array([ 1, 60, 1, 61]) Coordinates: * time (time) datetime64[ns] 1999-01-01 1999-03-01 2000-01-01 2000-03-01

In [13]: da.groupby(ordinal_day).mean('time') Out[13]: <xarray.DataArray (dayofyear: 3)> array([2., 2., 4.]) Coordinates: * dayofyear (dayofyear) int64 1 60 61 ```

{
    "total_count": 5,
    "+1": 5,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  How to broadcast along dayofyear 290023410
417855365 https://github.com/pydata/xarray/issues/1844#issuecomment-417855365 https://api.github.com/repos/pydata/xarray/issues/1844 MDEyOklzc3VlQ29tbWVudDQxNzg1NTM2NQ== spencerkclark 6628425 2018-09-01T12:09:25Z 2018-09-01T12:09:25Z MEMBER

@chiaral if I understand correctly, your data does use a standard calendar, but the issue is that you would like to group values based on matching month and day numbers (e.g. all January 1st's, all January 6th's, ..., all March 2nd's etc.) rather than matching "days since December 31st the preceding year," which is what the dayofyear attribute corresponds with. Is that right?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  How to broadcast along dayofyear 290023410

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 39.659ms · About: xarray-datasette