polars.date_range¶
- polars.date_range(low: datetime.datetime, high: datetime.datetime, interval: Union[str, datetime.timedelta], closed: Optional[str] = 'both', name: Optional[str] = None, time_unit: Optional[str] = None) polars.internals.series.Series ¶
Create a date range of type Datetime.
- Parameters
- low
Lower bound of the date range
- high
Upper bound of the date range
- interval
Interval periods A python timedelta object or a polars duration str e.g.: “3d12h4m25s” # 3 days, 12 hours, 4 minutes, and 25 seconds
- closed {None, ‘left’, ‘right’, ‘both’, ‘none’}
Make the interval closed to the ‘left’, ‘right’, ‘none’ or ‘both’ sides.
- name
Name of the output Series
- time_unit
Set the time unit; one of {‘ns’, ‘ms’}
- Returns
- A Series of type Datetime
Examples
>>> from datetime import datetime >>> pl.date_range(datetime(1985, 1, 1), datetime(2015, 7, 1), "1d12h") shape: (7426,) Series: '' [datetime[ns]] [ 1985-01-01 00:00:00 1985-01-02 12:00:00 1985-01-04 00:00:00 1985-01-05 12:00:00 1985-01-07 00:00:00 1985-01-08 12:00:00 1985-01-10 00:00:00 1985-01-11 12:00:00 1985-01-13 00:00:00 1985-01-14 12:00:00 1985-01-16 00:00:00 1985-01-17 12:00:00 ... 2015-06-14 00:00:00 2015-06-15 12:00:00 2015-06-17 00:00:00 2015-06-18 12:00:00 2015-06-20 00:00:00 2015-06-21 12:00:00 2015-06-23 00:00:00 2015-06-24 12:00:00 2015-06-26 00:00:00 2015-06-27 12:00:00 2015-06-29 00:00:00 2015-06-30 12:00:00 ]