xarray.date_range#
- xarray.date_range(start=None, end=None, periods=None, freq=None, tz=None, normalize=False, name=None, inclusive='both', unit='ns', calendar='standard', use_cftime=None)[source]#
Return a fixed frequency datetime index.
The type (
xarray.CFTimeIndex
orpandas.DatetimeIndex
) of the returned index depends on the requested calendar and on use_cftime.- Parameters:
start (
str
ordatetime-like
, optional) – Left bound for generating dates.end (
str
ordatetime-like
, optional) – Right bound for generating dates.periods (
int
, optional) – Number of periods to generate.freq (
str
orNone
, default:"D"
) – Frequency strings can have multiples, e.g. “5h” and negative values, e.g. “-1D”.tz (
str
ortzinfo
, optional) – Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. By default, the resulting DatetimeIndex is timezone-naive. Only valid with pandas DatetimeIndex.normalize (
bool
, default:False
) – Normalize start/end dates to midnight before generating date range.inclusive (
{"both", "neither", "left", "right"}
, default:"both"
) – Include boundaries; whether to set each bound as closed or open.New in version 2023.02.0.
unit (
{"s", "ms", "us", "ns"}
, default"ns"
) – Specify the desired resolution of the result.New in version 2024.12.0.
calendar (
str
, default:"standard"
) – Calendar type for the datetimes.use_cftime (
boolean
, optional) – If True, always return a CFTimeIndex. If False, return a pd.DatetimeIndex if possible or raise a ValueError. If None (default), return a pd.DatetimeIndex if possible, otherwise return a CFTimeIndex. Defaults to False if tz is not None.
- Returns:
CFTimeIndex
orpd.DatetimeIndex
See also