From 02c44bbbd381bd2600b0cec6df12cf4c8b539599 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Wed, 13 Jul 2016 00:59:05 +0200 Subject: [PATCH 1/4] Add reference to frequency strings; fixes #13160 --- doc/source/timeseries.rst | 13 ++++++++----- pandas/core/window.py | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 7e832af14c051..d414f336398e9 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -567,11 +567,11 @@ DateOffset objects ------------------ In the preceding examples, we created DatetimeIndex objects at various -frequencies by passing in frequency strings like 'M', 'W', and 'BM to the -``freq`` keyword. Under the hood, these frequency strings are being translated -into an instance of pandas ``DateOffset``, which represents a regular -frequency increment. Specific offset logic like "month", "business day", or -"one hour" is represented in its various subclasses. +frequencies by passing in :ref: `frequency strings ` +like 'M', 'W', and 'BM to the ``freq`` keyword. Under the hood, these frequency +strings are being translated into an instance of pandas ``DateOffset``, +which represents a regular frequency increment. Specific offset logic like +"month", "business day", or "one hour" is represented in its various subclasses. .. csv-table:: :header: "Class name", "Description" @@ -953,6 +953,9 @@ You can use keyword arguments suported by either ``BusinessHour`` and ``CustomBu # Monday is skipped because it's a holiday, business hour starts from 10:00 dt + bhour_mon * 2 + +.. _timeseries.offset_aliases: + Offset Aliases ~~~~~~~~~~~~~~ diff --git a/pandas/core/window.py b/pandas/core/window.py index 1e34d18fe3e54..7e3cc36a70fd3 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -312,6 +312,8 @@ class Window(_Window): * ``gaussian`` (needs std) * ``general_gaussian`` (needs power, width) * ``slepian`` (needs width). + + To know more about the frequency strings, please visit this link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ def validate(self): From 7b7045ae82e1fb4033ae11111e7fc8c93c409ed1 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Wed, 13 Jul 2016 01:12:23 +0200 Subject: [PATCH 2/4] DOC: Add reference to frequency strings in docs --- pandas/core/window.py | 3 ++- pandas/stats/moments.py | 21 +++++++++++++++++++++ pandas/tseries/index.py | 12 ++++++++++++ pandas/tseries/tdi.py | 6 ++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 7e3cc36a70fd3..8b7a975b59954 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -313,7 +313,8 @@ class Window(_Window): * ``general_gaussian`` (needs power, width) * ``slepian`` (needs width). - To know more about the frequency strings, please visit this link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ def validate(self): diff --git a/pandas/stats/moments.py b/pandas/stats/moments.py index 46d30ab7fe313..eb98cdd973740 100644 --- a/pandas/stats/moments.py +++ b/pandas/stats/moments.py @@ -271,6 +271,9 @@ def rolling_count(arg, window, **kwargs): The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('rolling', 'count', arg, window=window, **kwargs) @@ -521,6 +524,9 @@ def rolling_quantile(arg, window, quantile, min_periods=None, freq=None, The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('rolling', 'quantile', @@ -570,6 +576,9 @@ def rolling_apply(arg, window, func, min_periods=None, freq=None, The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('rolling', 'apply', @@ -642,6 +651,9 @@ def rolling_window(arg, window=None, win_type=None, min_periods=None, The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ func = 'mean' if mean else 'sum' return ensure_compat('rolling', @@ -707,6 +719,9 @@ def expanding_count(arg, freq=None): The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('expanding', 'count', arg, freq=freq) @@ -735,6 +750,9 @@ def expanding_quantile(arg, quantile, min_periods=1, freq=None): The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('expanding', 'quantile', @@ -818,6 +836,9 @@ def expanding_apply(arg, func, min_periods=1, freq=None, The `freq` keyword is used to conform time series data to a specified frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return ensure_compat('expanding', 'apply', diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index 9b36bc5907066..bcd1e9e1b15b4 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -178,6 +178,9 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin, Attempt to infer fall dst-transition hours based on order name : object Name to be stored in the index + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ _typ = 'datetimeindex' @@ -2071,6 +2074,9 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None, ----- 2 of start, end, or periods must be specified + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + Returns ------- rng : DatetimeIndex @@ -2111,6 +2117,9 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, ----- 2 of start, end, or periods must be specified + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + Returns ------- rng : DatetimeIndex @@ -2162,6 +2171,9 @@ def cdate_range(start=None, end=None, periods=None, freq='C', tz=None, ----- 2 of start, end, or periods must be specified + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + Returns ------- rng : DatetimeIndex diff --git a/pandas/tseries/tdi.py b/pandas/tseries/tdi.py index dbc0078b67ae7..d23fa699cd04c 100644 --- a/pandas/tseries/tdi.py +++ b/pandas/tseries/tdi.py @@ -101,6 +101,9 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index): the 'left', 'right', or both sides (None) name : object Name to be stored in the index + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ _typ = 'timedeltaindex' @@ -1001,6 +1004,9 @@ def timedelta_range(start=None, end=None, periods=None, freq='D', Returns ------- rng : TimedeltaIndex + + To know more about the frequency strings (offset aliases), please visit this + link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. """ return TimedeltaIndex(start=start, end=end, periods=periods, freq=freq, name=name, From fff5da7082aadcbb874d2e1f842c78c542019841 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Wed, 13 Jul 2016 21:58:04 +0200 Subject: [PATCH 3/4] Fix links and text for reference --- doc/source/timeseries.rst | 2 +- pandas/core/window.py | 4 ++-- pandas/stats/moments.py | 28 ++++++++++++++-------------- pandas/tseries/index.py | 16 ++++++++-------- pandas/tseries/tdi.py | 8 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index d414f336398e9..12480bbac7d64 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -567,7 +567,7 @@ DateOffset objects ------------------ In the preceding examples, we created DatetimeIndex objects at various -frequencies by passing in :ref: `frequency strings ` +frequencies by passing in :ref:`frequency strings ` like 'M', 'W', and 'BM to the ``freq`` keyword. Under the hood, these frequency strings are being translated into an instance of pandas ``DateOffset``, which represents a regular frequency increment. Specific offset logic like diff --git a/pandas/core/window.py b/pandas/core/window.py index 8b7a975b59954..c01464fe5028f 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -313,8 +313,8 @@ class Window(_Window): * ``general_gaussian`` (needs power, width) * ``slepian`` (needs width). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ def validate(self): diff --git a/pandas/stats/moments.py b/pandas/stats/moments.py index eb98cdd973740..2db28779b4263 100644 --- a/pandas/stats/moments.py +++ b/pandas/stats/moments.py @@ -272,8 +272,8 @@ def rolling_count(arg, window, **kwargs): frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('rolling', 'count', arg, window=window, **kwargs) @@ -525,8 +525,8 @@ def rolling_quantile(arg, window, quantile, min_periods=None, freq=None, frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('rolling', 'quantile', @@ -577,8 +577,8 @@ def rolling_apply(arg, window, func, min_periods=None, freq=None, frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('rolling', 'apply', @@ -652,8 +652,8 @@ def rolling_window(arg, window=None, win_type=None, min_periods=None, frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ func = 'mean' if mean else 'sum' return ensure_compat('rolling', @@ -720,8 +720,8 @@ def expanding_count(arg, freq=None): frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('expanding', 'count', arg, freq=freq) @@ -751,8 +751,8 @@ def expanding_quantile(arg, quantile, min_periods=1, freq=None): frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('expanding', 'quantile', @@ -837,8 +837,8 @@ def expanding_apply(arg, func, min_periods=1, freq=None, frequency by resampling the data. This is done with the default parameters of :meth:`~pandas.Series.resample` (i.e. using the `mean`). - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return ensure_compat('expanding', 'apply', diff --git a/pandas/tseries/index.py b/pandas/tseries/index.py index bcd1e9e1b15b4..79f3c139f5c03 100644 --- a/pandas/tseries/index.py +++ b/pandas/tseries/index.py @@ -179,8 +179,8 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin, name : object Name to be stored in the index - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ _typ = 'datetimeindex' @@ -2074,8 +2074,8 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None, ----- 2 of start, end, or periods must be specified - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. Returns ------- @@ -2117,8 +2117,8 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None, ----- 2 of start, end, or periods must be specified - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. Returns ------- @@ -2171,8 +2171,8 @@ def cdate_range(start=None, end=None, periods=None, freq='C', tz=None, ----- 2 of start, end, or periods must be specified - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. Returns ------- diff --git a/pandas/tseries/tdi.py b/pandas/tseries/tdi.py index d23fa699cd04c..b7bf2f2370d2a 100644 --- a/pandas/tseries/tdi.py +++ b/pandas/tseries/tdi.py @@ -102,8 +102,8 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index): name : object Name to be stored in the index - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ _typ = 'timedeltaindex' @@ -1005,8 +1005,8 @@ def timedelta_range(start=None, end=None, periods=None, freq='D', ------- rng : TimedeltaIndex - To know more about the frequency strings (offset aliases), please visit this - link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases. + To learn more about the frequency strings, please see `this link + `__. """ return TimedeltaIndex(start=start, end=end, periods=periods, freq=freq, name=name, From b45ae21a354d0f9c90af787e84c44b09a64b8715 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 17 Jul 2016 01:49:21 +0200 Subject: [PATCH 4/4] DOC: Add learn more text in generic and removed from window --- pandas/core/generic.py | 6 ++++++ pandas/core/window.py | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b4bcae47cbbdf..fb1808d46f08d 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3938,6 +3938,9 @@ def asfreq(self, freq, method=None, how=None, normalize=False): Returns ------- converted : type of caller + + To learn more about the frequency strings, please see `this link + `__. """ from pandas.tseries.resample import asfreq return asfreq(self, freq, method=method, how=how, normalize=normalize) @@ -4009,6 +4012,9 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, range from 0 through 4. Defaults to 0 + To learn more about the offset strings, please see `this link + `__. + Examples -------- diff --git a/pandas/core/window.py b/pandas/core/window.py index c01464fe5028f..1e34d18fe3e54 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -312,9 +312,6 @@ class Window(_Window): * ``gaussian`` (needs std) * ``general_gaussian`` (needs power, width) * ``slepian`` (needs width). - - To learn more about the frequency strings, please see `this link - `__. """ def validate(self):