Skip to content

Commit

Permalink
DOC: update the pandas.date_range() docstring (pandas-dev#20143)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nipunsadvilkar authored and TomAugspurger committed Mar 11, 2018
1 parent 6d7272a commit b3d6ce6
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2204,29 +2204,30 @@ def _generate_regular_range(start, end, periods, offset):
def date_range(start=None, end=None, periods=None, freq='D', tz=None,
normalize=False, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with day (calendar) as the default
frequency
Return a fixed frequency DatetimeIndex.
The default frequency is day (calendar).
Parameters
----------
start : string or datetime-like, default None
Left bound for generating dates
Left bound for generating dates.
end : string or datetime-like, default None
Right bound for generating dates
Right bound for generating dates.
periods : integer, default None
Number of periods to generate
Number of periods to generate.
freq : string or DateOffset, default 'D' (calendar daily)
Frequency strings can have multiples, e.g. '5H'
Frequency strings can have multiples, e.g. '5H'.
tz : string, default None
Time zone name for returning localized DatetimeIndex, for example
Asia/Hong_Kong
Asia/Hong_Kong.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range
Normalize start/end dates to midnight before generating date range.
name : string, default None
Name of the resulting DatetimeIndex
Name of the resulting DatetimeIndex.
closed : string, default None
Make the interval closed with respect to the given frequency to
the 'left', 'right', or both sides (None)
the 'left', 'right', or both sides (None).
Notes
-----
Expand All @@ -2239,6 +2240,22 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None,
Returns
-------
rng : DatetimeIndex
See Also
--------
pandas.period_range : Return a fixed frequency PeriodIndex.
pandas.interval_range : Return a fixed frequency IntervalIndex.
Examples
--------
>>> pd.date_range('2018-10-03', periods=2) # doctest: +NORMALIZE_WHITESPACE
DatetimeIndex(['2018-10-03', '2018-10-04'], dtype='datetime64[ns]',
freq='D')
>>> pd.date_range(start='2018-01-01', end='20180103')
... # doctest: +NORMALIZE_WHITESPACE
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
dtype='datetime64[ns]', freq='D')
"""
return DatetimeIndex(start=start, end=end, periods=periods,
freq=freq, tz=tz, normalize=normalize, name=name,
Expand Down

0 comments on commit b3d6ce6

Please sign in to comment.