w3resource

Pandas: Data Manipulation - date_range() function

date_range() function

The date_range() function is usede to get a fixed frequency DatetimeIndex.

Syntax:

pandas.date_range(start=None, end=None, periods=None, freq=None, tz=None, normalize=False, name=None, closed=None, **kwargs)

Parameters:

Name Description Type / Default Value Required / Optional
start Left bound for generating dates. str or datetime-like Optional
end Right bound for generating dates. str or datetime-like Optional
periods Number of periods to generate. integer Optional
freq Frequency strings can have multiples, e.g. ‘5H’. str or DateOffset
Default Value: 'D'
Required
tz Time zone name for returning localized DatetimeIndex, for example ‘Asia/Hong_Kong’. str or tzinfo
Default Value: The resulting DatetimeIndex is timezone-naive.
Optional
normalize Normalize start/end dates to midnight before generating date range. bool
Default Value : False.
Required
name Name of the resulting DatetimeIndex. str
Default Value: None
Required
closed Make the interval closed with respect to the given frequency to the ‘left’, ‘right’, or both sides. {None, ‘left’, ‘right’}
Default Value: None
Optional
**kwargs For compatibility. Has no effect on the result.

Returns: rng - DatetimeIndex

Example:


Download the above Notebook from here.

Previous: to_timedelta() function
Next: bdate_range() function