home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 334233567

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/1605#issuecomment-334233567 https://api.github.com/repos/pydata/xarray/issues/1605 334233567 MDEyOklzc3VlQ29tbWVudDMzNDIzMzU2Nw== 2443309 2017-10-04T17:40:00Z 2017-10-04T17:40:00Z MEMBER

Okay, I got it now. Consider this example

```Python dates = pd.date_range('2016-01-01', '2016-12-31', freq='D')

orig = dates[dates != '2016-02-29'] # drop feb 29 and this example will work

orig = dates

da = xr.DataArray(np.random.random((len(orig), 2, 3)), dims=('time', 'x', 'y'), coords={'time': orig}) print(da)

da.resample(time='1D').interpolate('linear') <xarray.DataArray (time: 366, x: 2, y: 3)> array([[[ 0.390107, 0.257026, 0.155619], [ 0.151772, 0.98012 , 0.61582 ]],

   [[ 0.081488,  0.038706,  0.627044],
    [ 0.840926,  0.778831,  0.102756]],

   ..., 
   [[ 0.94791 ,  0.274371,  0.582416],
    [ 0.544428,  0.351174,  0.603062]],

   [[ 0.166722,  0.507593,  0.841115],
    [ 0.099317,  0.649383,  0.842175]]])

Coordinates: * time (time) datetime64[ns] 2016-01-01 2016-01-02 2016-01-03 ... Dimensions without coordinates: x, y


AttributeError Traceback (most recent call last) <ipython-input-12-e187a9baeec8> in <module>() 6 print(da) 7 ----> 8 da.resample(time='1d').interpolate('linear')

~/Dropbox/src/xarray/xarray/core/resample.py in interpolate(self, kind) 110 111 """ --> 112 return self._interpolate(kind=kind) 113 114 def _interpolate(self, kind='linear'):

~/Dropbox/src/xarray/xarray/core/resample.py in _interpolate(self, kind) 204 f = interp1d(x, y, kind=kind, axis=axis, bounds_error=True, 205 assume_sorted=True) --> 206 new_x = self._full_index.values.astype('float') 207 208 # construct new up-sampled DataArray

AttributeError: 'NoneType' object has no attribute 'values' ```

The application here is that I'm doing a QC check on a dataset that is sometimes missing Feb 29. It is sufficient for my application to always resample and fill Feb 29 when its missing. The pandas equivalent works:

Python s = pd.Series(np.random.random((len(orig))), index=orig) new = s.resample('1D').interpolate('linear') new.equals(s) True

I think I have a fix for this which I'll push up quickly.

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