home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 453665698

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/2667#issuecomment-453665698 https://api.github.com/repos/pydata/xarray/issues/2667 453665698 MDEyOklzc3VlQ29tbWVudDQ1MzY2NTY5OA== 6815844 2019-01-11T21:40:50Z 2019-01-11T21:40:50Z MEMBER

Is there a good way to convert a timedelta array including NaT to a float array with nan? array.astype(float) makes NaT a certain large value. ```python 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]) ```

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