Skip to content

Commit b3d6ce6

Browse files
nipunsadvilkarTomAugspurger
authored andcommitted
DOC: update the pandas.date_range() docstring (pandas-dev#20143)
* DOC: Improved the docstring of pandas.date_range() * Change date strings to iso format * Removed import pands in Examples docstring * Add See Also Docstring * Update datetimes.py * Doctests
1 parent 6d7272a commit b3d6ce6

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

pandas/core/indexes/datetimes.py

+27-10
Original file line numberDiff line numberDiff line change
@@ -2204,29 +2204,30 @@ def _generate_regular_range(start, end, periods, offset):
22042204
def date_range(start=None, end=None, periods=None, freq='D', tz=None,
22052205
normalize=False, name=None, closed=None, **kwargs):
22062206
"""
2207-
Return a fixed frequency DatetimeIndex, with day (calendar) as the default
2208-
frequency
2207+
Return a fixed frequency DatetimeIndex.
2208+
2209+
The default frequency is day (calendar).
22092210
22102211
Parameters
22112212
----------
22122213
start : string or datetime-like, default None
2213-
Left bound for generating dates
2214+
Left bound for generating dates.
22142215
end : string or datetime-like, default None
2215-
Right bound for generating dates
2216+
Right bound for generating dates.
22162217
periods : integer, default None
2217-
Number of periods to generate
2218+
Number of periods to generate.
22182219
freq : string or DateOffset, default 'D' (calendar daily)
2219-
Frequency strings can have multiples, e.g. '5H'
2220+
Frequency strings can have multiples, e.g. '5H'.
22202221
tz : string, default None
22212222
Time zone name for returning localized DatetimeIndex, for example
2222-
Asia/Hong_Kong
2223+
Asia/Hong_Kong.
22232224
normalize : bool, default False
2224-
Normalize start/end dates to midnight before generating date range
2225+
Normalize start/end dates to midnight before generating date range.
22252226
name : string, default None
2226-
Name of the resulting DatetimeIndex
2227+
Name of the resulting DatetimeIndex.
22272228
closed : string, default None
22282229
Make the interval closed with respect to the given frequency to
2229-
the 'left', 'right', or both sides (None)
2230+
the 'left', 'right', or both sides (None).
22302231
22312232
Notes
22322233
-----
@@ -2239,6 +2240,22 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None,
22392240
Returns
22402241
-------
22412242
rng : DatetimeIndex
2243+
2244+
See Also
2245+
--------
2246+
pandas.period_range : Return a fixed frequency PeriodIndex.
2247+
pandas.interval_range : Return a fixed frequency IntervalIndex.
2248+
2249+
Examples
2250+
--------
2251+
>>> pd.date_range('2018-10-03', periods=2) # doctest: +NORMALIZE_WHITESPACE
2252+
DatetimeIndex(['2018-10-03', '2018-10-04'], dtype='datetime64[ns]',
2253+
freq='D')
2254+
2255+
>>> pd.date_range(start='2018-01-01', end='20180103')
2256+
... # doctest: +NORMALIZE_WHITESPACE
2257+
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
2258+
dtype='datetime64[ns]', freq='D')
22422259
"""
22432260
return DatetimeIndex(start=start, end=end, periods=periods,
22442261
freq=freq, tz=tz, normalize=normalize, name=name,

0 commit comments

Comments
 (0)