Skip to content

DOC: Add reference to frequency strings #13632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <timeseries.offset_aliases>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space after the :ref:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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"
Expand Down Expand Up @@ -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
~~~~~~~~~~~~~~

Expand Down
3 changes: 3 additions & 0 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ class Window(_Window):
* ``gaussian`` (needs std)
* ``general_gaussian`` (needs power, width)
* ``slepian`` (needs width).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main one that is missed is generic.resample

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also generic.asfreq

actually there are quite a few more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will find and add everywhere once the text is finalized.

To know more about the frequency strings (offset aliases), please visit this
link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see how links are done, look at core/frame.py/to_latex.

To learn more about .....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :)

"""

def validate(self):
Expand Down
21 changes: 21 additions & 0 deletions pandas/stats/moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

link - http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases.
"""
return ensure_compat('rolling', 'count', arg, window=window, **kwargs)

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 12 additions & 0 deletions pandas/tseries/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pandas/tseries/tdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down