@@ -98,13 +98,18 @@ coordinate with dates from a no-leap calendar and a
98
98
]
99
99
da = xr.DataArray(np.arange(24 ), coords = [dates], dims = [" time" ], name = " foo" )
100
100
101
- Xarray also includes a :py:func: `~xarray.cftime_range ` function, which enables
101
+ Xarray also includes a :py:func: `~xarray.date_range ` function, which enables
102
102
creating a :py:class: `~xarray.CFTimeIndex ` with regularly-spaced dates. For
103
- instance, we can create the same dates and DataArray we created above using:
103
+ instance, we can create the same dates and DataArray we created above using
104
+ (note that ``use_cftime=True `` is not mandatory to return a
105
+ :py:class: `~xarray.CFTimeIndex ` for non-standard calendars, but can be nice
106
+ to use to be explicit):
104
107
105
108
.. ipython :: python
106
109
107
- dates = xr.cftime_range(start = " 0001" , periods = 24 , freq = " MS" , calendar = " noleap" )
110
+ dates = xr.date_range(
111
+ start = " 0001" , periods = 24 , freq = " MS" , calendar = " noleap" , use_cftime = True
112
+ )
108
113
da = xr.DataArray(np.arange(24 ), coords = [dates], dims = [" time" ], name = " foo" )
109
114
110
115
Mirroring pandas' method with the same name, :py:meth: `~xarray.infer_freq ` allows one to
@@ -138,7 +143,9 @@ use ``pandas`` when possible, i.e. when the calendar is ``standard``/``gregorian
138
143
139
144
.. ipython :: python
140
145
141
- dates = xr.cftime_range(start = " 2001" , periods = 24 , freq = " MS" , calendar = " noleap" )
146
+ dates = xr.date_range(
147
+ start = " 2001" , periods = 24 , freq = " MS" , calendar = " noleap" , use_cftime = True
148
+ )
142
149
da_nl = xr.DataArray(np.arange(24 ), coords = [dates], dims = [" time" ], name = " foo" )
143
150
da_std = da.convert_calendar(" standard" , use_cftime = True )
144
151
0 commit comments