modin.pandas.date_range

snowflake.snowpark.modin.pandas.general.date_range(start: VALID_DATE_TYPE | None = None, end: VALID_DATE_TYPE | None = None, periods: int | None = None, freq: str | pd.DateOffset | None = None, tz: str | tzinfo | None = None, normalize: bool = False, name: Hashable | None = None, inclusive: IntervalClosedType = 'both', **kwargs) Series[source]

Return a fixed frequency series.

Returns the range of equally spaced time points (where the difference between any two adjacent points is specified by the given frequency) such that they all satisfy start <[=] x <[=] end, where the first one and the last one are, resp., the first and last time points in that range that fall on the boundary of freq (if given as a frequency string) or that are valid for freq (if given as a pandas.tseries.offsets.DateOffset). (If exactly one of start, end, or freq is not specified, this missing parameter can be computed given periods, the number of timesteps in the range. See the note below.)

Parameters:
  • start (str or datetime-like, optional) – Left bound for generating dates.

  • end (str or datetime-like, optional) – Right bound for generating dates.

  • periods (int, optional) – Number of periods to generate.

  • freq (str or DateOffset, default 'D') – Frequency strings can have multiples, e.g. ‘5H’.

  • tz (str or tzinfo, optional) – Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. By default, the resulting DatetimeIndex is timezone-naive.

  • normalize (bool, default False) – Normalize start/end dates to midnight before generating date range.

  • name (str, default None) – Name of the resulting DatetimeIndex.

  • inclusive ({"both", "neither", "left", "right"}, default "both") –

    Include boundaries; Whether to set each bound as closed or open.

    New in version 1.4.0.

  • **kwargs – For compatibility. Has no effect on the result.

Returns:

rng

Return type:

DatetimeIndex

See also

DatetimeIndex

An immutable container for datetimes.

timedelta_range

Return a fixed frequency TimedeltaIndex.

period_range

Return a fixed frequency PeriodIndex.

interval_range

Return a fixed frequency IntervalIndex.

Notes

tz is not supported.

Of the four parameters start, end, periods, and freq, exactly three must be specified. If freq is omitted, the resulting DatetimeIndex will have periods linearly spaced elements between start and end (closed on both sides).

To learn more about the frequency strings, please see this link.

Also, custom or business frequencies are not implemented in Snowpark pandas, e.g., “B”, “C”, “SMS”, “BMS”, “CBMS”, “BQS”, “BYS”, “bh”, “cbh”.

Examples

Specifying the values

The next four examples generate the same DatetimeIndex, but vary the combination of start, end and periods.

Specify start and end, with the default daily frequency.

>>> pd.date_range(start='1/1/2018', end='1/08/2018')
0   2018-01-01
1   2018-01-02
2   2018-01-03
3   2018-01-04
4   2018-01-05
5   2018-01-06
6   2018-01-07
7   2018-01-08
dtype: datetime64[ns]
Copy

Specify start and periods, the number of periods (days).

>>> pd.date_range(start='1/1/2018', periods=8)
0   2018-01-01
1   2018-01-02
2   2018-01-03
3   2018-01-04
4   2018-01-05
5   2018-01-06
6   2018-01-07
7   2018-01-08
dtype: datetime64[ns]
Copy

Specify end and periods, the number of periods (days).

>>> pd.date_range(end='1/1/2018', periods=8)
0   2017-12-25
1   2017-12-26
2   2017-12-27
3   2017-12-28
4   2017-12-29
5   2017-12-30
6   2017-12-31
7   2018-01-01
dtype: datetime64[ns]
Copy

Specify start, end, and periods; the frequency is generated automatically (linearly spaced).

>>> pd.date_range(start='2018-04-24', end='2018-04-27', periods=3)
0   2018-04-24 00:00:00
1   2018-04-25 12:00:00
2   2018-04-27 00:00:00
dtype: datetime64[ns]
Copy

Other Parameters

Changed the freq (frequency) to 'ME' (month end frequency).

>>> pd.date_range(start='1/1/2018', periods=5, freq='ME')
0   2018-01-31
1   2018-02-28
2   2018-03-31
3   2018-04-30
4   2018-05-31
dtype: datetime64[ns]
Copy

Multiples are allowed

>>> pd.date_range(start='1/1/2018', periods=5, freq='3ME')
0   2018-01-31
1   2018-04-30
2   2018-07-31
3   2018-10-31
4   2019-01-31
dtype: datetime64[ns]
Copy

freq can also be specified as an Offset object.

>>> pd.date_range(start='1/1/2018', periods=5, freq=pd.offsets.MonthEnd(3))
0   2018-01-31
1   2018-04-30
2   2018-07-31
3   2018-10-31
4   2019-01-31
dtype: datetime64[ns]
Copy

inclusive controls whether to include start and end that are on the boundary. The default, “both”, includes boundary points on either end.

>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive="both")
0   2017-01-01
1   2017-01-02
2   2017-01-03
3   2017-01-04
dtype: datetime64[ns]
Copy

Use inclusive='left' to exclude end if it falls on the boundary.

>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive='left')
0   2017-01-01
1   2017-01-02
2   2017-01-03
dtype: datetime64[ns]
Copy

Use inclusive='right' to exclude start if it falls on the boundary, and similarly inclusive='neither' will exclude both start and end.

>>> pd.date_range(start='2017-01-01', end='2017-01-04', inclusive='right')
0   2017-01-02
1   2017-01-03
2   2017-01-04
dtype: datetime64[ns]
Copy