Return a fixed frequency datetime index. The type (:py:class:`xarray.CFTimeIndex` or :py:class:`pandas.DatetimeIndex`) of the returned index depends on the requested calendar and on `use_cftime`. Parameters ---------- start : str or datetime-like, optional Left bound fo
(
start=None,
end=None,
periods=None,
freq=None,
tz=None,
normalize=False,
name=None,
inclusive: InclusiveOptions = "both",
unit: PDDatetimeUnitOptions = "ns",
calendar="standard",
use_cftime=None,
)
| 1219 | |
| 1220 | |
| 1221 | def date_range( |
| 1222 | start=None, |
| 1223 | end=None, |
| 1224 | periods=None, |
| 1225 | freq=None, |
| 1226 | tz=None, |
| 1227 | normalize=False, |
| 1228 | name=None, |
| 1229 | inclusive: InclusiveOptions = "both", |
| 1230 | unit: PDDatetimeUnitOptions = "ns", |
| 1231 | calendar="standard", |
| 1232 | use_cftime=None, |
| 1233 | ): |
| 1234 | """Return a fixed frequency datetime index. |
| 1235 | |
| 1236 | The type (:py:class:`xarray.CFTimeIndex` or :py:class:`pandas.DatetimeIndex`) |
| 1237 | of the returned index depends on the requested calendar and on `use_cftime`. |
| 1238 | |
| 1239 | Parameters |
| 1240 | ---------- |
| 1241 | start : str or datetime-like, optional |
| 1242 | Left bound for generating dates. |
| 1243 | end : str or datetime-like, optional |
| 1244 | Right bound for generating dates. |
| 1245 | periods : int, optional |
| 1246 | Number of periods to generate. |
| 1247 | freq : str or None, default: "D" |
| 1248 | Frequency strings can have multiples, e.g. "5h" and negative values, e.g. "-1D". |
| 1249 | tz : str or tzinfo, optional |
| 1250 | Time zone name for returning localized DatetimeIndex, for example |
| 1251 | 'Asia/Hong_Kong'. By default, the resulting DatetimeIndex is |
| 1252 | timezone-naive. Only valid with pandas DatetimeIndex. |
| 1253 | normalize : bool, default: False |
| 1254 | Normalize start/end dates to midnight before generating date range. |
| 1255 | name : str, default: None |
| 1256 | Name of the resulting index |
| 1257 | inclusive : {"both", "neither", "left", "right"}, default: "both" |
| 1258 | Include boundaries; whether to set each bound as closed or open. |
| 1259 | |
| 1260 | .. versionadded:: 2023.02.0 |
| 1261 | unit : {"s", "ms", "us", "ns"}, default "ns" |
| 1262 | Specify the desired resolution of the result. |
| 1263 | |
| 1264 | .. versionadded:: 2024.12.0 |
| 1265 | calendar : str, default: "standard" |
| 1266 | Calendar type for the datetimes. |
| 1267 | use_cftime : boolean, optional |
| 1268 | If True, always return a CFTimeIndex. |
| 1269 | If False, return a pd.DatetimeIndex if possible or raise a ValueError. |
| 1270 | If None (default), return a pd.DatetimeIndex if possible, |
| 1271 | otherwise return a CFTimeIndex. Overridden to False if `tz` is not None. |
| 1272 | |
| 1273 | Returns |
| 1274 | ------- |
| 1275 | CFTimeIndex or pd.DatetimeIndex |
| 1276 | |
| 1277 | Notes |
| 1278 | ----- |
searching dependent graphs…