From 586f39d6d71eee0630ce6895a1f1c4940454cf09 Mon Sep 17 00:00:00 2001 From: Steven Cook Date: Sat, 25 Aug 2018 20:20:08 +1000 Subject: [PATCH 1/2] DOC: Updated docstrings related to DateTimeIndex. GH22459 --- pandas/core/indexes/datetimes.py | 34 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 019aad4941d26..5b2e3ea1052bf 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -1652,7 +1652,8 @@ def date_range(start=None, end=None, periods=None, freq=None, tz=None, >>> pd.date_range(start='2018-04-24', end='2018-04-27', periods=3) DatetimeIndex(['2018-04-24 00:00:00', '2018-04-25 12:00:00', - '2018-04-27 00:00:00'], freq=None) + '2018-04-27 00:00:00'], + dtype='datetime64[ns]', freq=None) **Other Parameters** @@ -1723,37 +1724,39 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, 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 'B' (business daily) - Frequency strings can have multiples, e.g. '5H' + Frequency strings can have multiples, e.g. '5H'. tz : string or None Time zone name for returning localized DatetimeIndex, for example - Asia/Beijing + Asia/Beijing. 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. weekmask : string or None, default None Weekmask of valid business days, passed to ``numpy.busdaycalendar``, only used when custom frequency strings are passed. The default - value None is equivalent to 'Mon Tue Wed Thu Fri' + value None is equivalent to 'Mon Tue Wed Thu Fri'. .. versionadded:: 0.21.0 holidays : list-like or None, default None Dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar``, only used when custom frequency strings - are passed + are passed. .. versionadded:: 0.21.0 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). + **kwargs + For compatibility. Has no effect on the result. Notes ----- @@ -1765,6 +1768,15 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, To learn more about the frequency strings, please see `this link `__. + Examples + -------- + Note how the two weekend days are skipped in the result. + + >>> pd.bdate_range(start='1/1/2018', end='1/08/2018') + DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04', + '2018-01-05', '2018-01-08'], + dtype='datetime64[ns]', freq='B') + Returns ------- rng : DatetimeIndex From 4e048869ec709b0fe02b8c80d611c61328355d90 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 18 Sep 2018 13:50:04 +0100 Subject: [PATCH 2/2] Fixing location and format of the Returns section --- pandas/core/indexes/datetimes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 5b2e3ea1052bf..96708ee242b58 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -1768,6 +1768,10 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, To learn more about the frequency strings, please see `this link `__. + Returns + ------- + DatetimeIndex + Examples -------- Note how the two weekend days are skipped in the result. @@ -1776,10 +1780,6 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04', '2018-01-05', '2018-01-08'], dtype='datetime64[ns]', freq='B') - - Returns - ------- - rng : DatetimeIndex """ if freq is None: msg = 'freq must be specified for bdate_range; use date_range instead'