I recently tried to change monthly near-surface air temperature in HadCM3 NetCDF time-object from past1000 experiment (from 850 AD to 1850 AD) to datetime object using xarray.CFTimeIndex.to_datetimeindex function:
xr.CFTimeIndex.to_datetimeindex(tas['time'])
and got this message:
OutOfBoundsDatetime                       Traceback (most recent call last)
~/anaconda3/envs/tutorial_xarray/lib/python3.7/site-packages/xarray/coding/times.py in cftime_to_nptime(times)
    296             dt = pd.Timestamp(
--> 297                 t.year, t.month, t.day, t.hour, t.minute, t.second, t.microsecond
    298             )
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps.Timestamp.__new__()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.convert_to_tsobject()
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.convert_datetime_to_tsobject()
pandas/_libs/tslibs/np_datetime.pyx in pandas._libs.tslibs.np_datetime.check_dts_bounds()
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 850-01-16 00:00:00
During handling of the above exception, another exception occurred:
ValueError                                Traceback (most recent call last)
<ipython-input-30-7ed217c97bf1> in <module>
----> 1 xr.CFTimeIndex.to_datetimeindex(tas['time'])
~/anaconda3/envs/tutorial_xarray/lib/python3.7/site-packages/xarray/coding/cftimeindex.py in to_datetimeindex(self, unsafe)
    486         DatetimeIndex(['2000-01-01', '2000-01-02'], dtype='datetime64[ns]', freq=None)
    487         """
--> 488         nptimes = cftime_to_nptime(self)
    489         calendar = infer_calendar_name(self)
    490         if calendar not in _STANDARD_CALENDARS and not unsafe:
~/anaconda3/envs/tutorial_xarray/lib/python3.7/site-packages/xarray/coding/times.py in cftime_to_nptime(times)
    300             raise ValueError(
    301                 "Cannot convert date {} to a date in the "
--> 302                 "standard calendar.  Reason: {}.".format(t, e)
    303             )
    304         new[i] = np.datetime64(dt)
ValueError: Cannot convert date 0850-01-16 00:00:00 to a date in the standard calendar.  Reason: Out of bounds nanosecond timestamp: 850-01-16 00:00:00.
This is my tas object:
<xarray.DataArray 'tas' (time: 12012, lat: 73, lon: 96)>
[84180096 values with dtype=float32]
Coordinates:
  * time     (time) object 0850-01-16 00:00:00 ... 1850-12-16 00:00:00
  * lat      (lat) float64 -90.0 -87.5 -85.0 -82.5 -80.0 ... 82.5 85.0 87.5 90.0
  * lon      (lon) float64 0.0 3.75 7.5 11.25 15.0 ... 345.0 348.8 352.5 356.2
    height   float64 ...
Attributes:
    standard_name:     air_temperature
    long_name:         Near-Surface Air Temperature
    units:             K
    original_name:     mo: m01s03i236
    cell_methods:      time: mean
    cell_measures:     area: areacella
    history:           2013-03-06T13:59:55Z altered by CMOR: Treated scalar d...
    associated_files:  baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation...
and I'm currently using:
$ pip freeze | grep xarray
xarray==0.15.0
Based on the the previous question, I know that he timespan that can be represented using a 64-bit integer is limited to approximately 584 years in pandas (of which this function built on-top).
Could anyone help me to convert this data to datetime object?
Thanks
