home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 375455202

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/2007#issuecomment-375455202 https://api.github.com/repos/pydata/xarray/issues/2007 375455202 MDEyOklzc3VlQ29tbWVudDM3NTQ1NTIwMg== 10194086 2018-03-22T20:57:59Z 2018-03-22T20:57:59Z MEMBER

I think what I want is like the filter function in R with circular=True.

I found two possibilities but they are quite "hand made" and certainly not very efficient

Solution with slicing: ``` python

take the last and first elements and append/ prepend them

first = ds[:15] last = ds[-15:] extended = xr.concat([last, ds, first], 'dayofyear')

do the rolling on the extended ds and get rid of NaNs

sol1 = extended.rolling(dayofyear=31, center=True).mean().dropna('dayofyear') ```

Solution with roll: python roll1 = ds.roll(dayofyear=150).rolling(dayofyear=31, center=True).mean() roll2 = ds.rolling(dayofyear=31, center=True).mean() sol2 = xr.concat([roll1, roll2], dim='r').mean('r') Call rolling on original and rolled dataset, and put them together again.

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