xarray.CFTimeIndex.to_datetimeindex#
- CFTimeIndex.to_datetimeindex(unsafe=False, time_unit=None)[source] #
If possible, convert this index to a pandas.DatetimeIndex.
- Parameters:
- Returns:
- Raises:
ValueError – If the CFTimeIndex contains dates that are not possible in the standard calendar or outside the range representable by the specified
time_unit.- Warns:
RuntimeWarning – If converting from a non-standard calendar, or a Gregorian calendar with dates prior to the reform (1582年10月15日).
Warning
Note that for non-proleptic Gregorian calendars, this will change the calendar type of the index. In that case the result of this method should be used with caution.
Examples
>>> times = xr.date_range( ... "2000", periods=2, calendar="gregorian", use_cftime=True ... ) >>> times CFTimeIndex([2000年01月01日 00:00:00, 2000年01月02日 00:00:00], dtype='object', length=2, calendar='standard', freq=None) >>> times.to_datetimeindex(time_unit="ns") DatetimeIndex(['2000年01月01日', '2000年01月02日'], dtype='datetime64[ns]', freq=None)