-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
datetime interpolation doesn't work #2667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oops. This is definitely my bug. This line should return a Variable. I will send a fix. |
Is there a good way to convert a timedelta array including In [1]: import numpy as np
In [2]: import pandas as pd
In [3]: time = np.array(pd.date_range('15/12/1999', periods=11))
In [4]: time[8: 11] = np.nan
In [5]: time
Out[5]:
array(['1999-12-15T00:00:00.000000000', '1999-12-16T00:00:00.000000000',
'1999-12-17T00:00:00.000000000', '1999-12-18T00:00:00.000000000',
'1999-12-19T00:00:00.000000000', '1999-12-20T00:00:00.000000000',
'1999-12-21T00:00:00.000000000', '1999-12-22T00:00:00.000000000',
'NaT', 'NaT',
'NaT'], dtype='datetime64[ns]')
In [6]: time.astype(float)
Out[6]:
array([ 9.45216000e+17, 9.45302400e+17, 9.45388800e+17, 9.45475200e+17,
9.45561600e+17, 9.45648000e+17, 9.45734400e+17, 9.45820800e+17,
-9.22337204e+18, -9.22337204e+18, -9.22337204e+18])
In [7]: (time - np.min(time)).astype(float)
Out[7]:
array([ 0.00000000e+00, 8.64000000e+13, 1.72800000e+14, 2.59200000e+14,
3.45600000e+14, 4.32000000e+14, 5.18400000e+14, 6.04800000e+14,
-9.22337204e+18, -9.22337204e+18, -9.22337204e+18]) |
I think the best we can do is to is use masking on the result, e.g., with |
Thanks. Then, it would be probably nice if |
Code Sample, a copy-pastable example if possible
This code doesn't work anymore on master.
Problem description
The above code now raises the error
I think the issue is this line which returns a numpy array instead of a Variable. This was added in the
coarsen
PR (cc @fujiisoup)xarray/xarray/core/utils.py
Line 636 in d4c4682
The text was updated successfully, but these errors were encountered: