Skip to content

Commit 4caacdf

Browse files
sahildua2305jorisvandenbossche
authored andcommitted
DOC: Add reference to frequency strings
- [x] closes #13160 Author: Sahil Dua <[email protected]> This patch had conflicts when merged, resolved by Committer: Joris Van den Bossche <[email protected]> Closes #13632 from sahildua2305/frequency-strings-fix and squashes the following commits: b45ae21 [Sahil Dua] DOC: Add learn more text in generic and removed from window fff5da7 [Sahil Dua] Fix links and text for reference 7b7045a [Sahil Dua] DOC: Add reference to frequency strings in docs 02c44bb [Sahil Dua] Add reference to frequency strings; fixes #13160
1 parent 4d3b6c1 commit 4caacdf

File tree

6 files changed

+52
-7
lines changed

6 files changed

+52
-7
lines changed

doc/source/timeseries.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ DateOffset objects
567567
------------------
568568

569569
In the preceding examples, we created DatetimeIndex objects at various
570-
frequencies by passing in frequency strings like 'M', 'W', and 'BM to the
571-
``freq`` keyword. Under the hood, these frequency strings are being translated
572-
into an instance of pandas ``DateOffset``, which represents a regular
573-
frequency increment. Specific offset logic like "month", "business day", or
574-
"one hour" is represented in its various subclasses.
570+
frequencies by passing in :ref:`frequency strings <timeseries.offset_aliases>`
571+
like 'M', 'W', and 'BM to the ``freq`` keyword. Under the hood, these frequency
572+
strings are being translated into an instance of pandas ``DateOffset``,
573+
which represents a regular frequency increment. Specific offset logic like
574+
"month", "business day", or "one hour" is represented in its various subclasses.
575575

576576
.. csv-table::
577577
:header: "Class name", "Description"
@@ -953,7 +953,7 @@ You can use keyword arguments suported by either ``BusinessHour`` and ``CustomBu
953953
# Monday is skipped because it's a holiday, business hour starts from 10:00
954954
dt + bhour_mon * 2
955955
956-
.. _timeseries.alias:
956+
.. _timeseries.offset_aliases:
957957

958958
Offset Aliases
959959
~~~~~~~~~~~~~~

doc/source/whatsnew/v0.19.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ Removal of prior version deprecations/changes
622622
pandas/tseries/frequencies.py:465: FutureWarning: Freq "W@MON" is deprecated, use "W-MON" as alternative.
623623
Out[2]: DatetimeIndex(['2016-07-04', '2016-07-11', '2016-07-18'], dtype='datetime64[ns]', freq='W-MON')
624624

625-
Now legacy time rules raises ``ValueError``. For the list of currently supported offsets, see :ref:`here <timeseries.alias>`
625+
Now legacy time rules raises ``ValueError``. For the list of currently supported offsets, see :ref:`here <timeseries.offset_aliases>`
626626

627627
- The ``tquery`` and ``uquery`` functions in the ``pandas.io.sql`` module are removed (:issue:`5950`).
628628

pandas/core/generic.py

+6
Original file line numberDiff line numberDiff line change
@@ -3982,6 +3982,9 @@ def asfreq(self, freq, method=None, how=None, normalize=False):
39823982
Returns
39833983
-------
39843984
converted : type of caller
3985+
3986+
To learn more about the frequency strings, please see `this link
3987+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
39853988
"""
39863989
from pandas.tseries.resample import asfreq
39873990
return asfreq(self, freq, method=method, how=how, normalize=normalize)
@@ -4053,6 +4056,9 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
40534056
range from 0 through 4. Defaults to 0
40544057
40554058
4059+
To learn more about the offset strings, please see `this link
4060+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
4061+
40564062
Examples
40574063
--------
40584064

pandas/stats/moments.py

+21
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def rolling_count(arg, window, **kwargs):
271271
The `freq` keyword is used to conform time series data to a specified
272272
frequency by resampling the data. This is done with the default parameters
273273
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
274+
275+
To learn more about the frequency strings, please see `this link
276+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
274277
"""
275278
return ensure_compat('rolling', 'count', arg, window=window, **kwargs)
276279

@@ -521,6 +524,9 @@ def rolling_quantile(arg, window, quantile, min_periods=None, freq=None,
521524
The `freq` keyword is used to conform time series data to a specified
522525
frequency by resampling the data. This is done with the default parameters
523526
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
527+
528+
To learn more about the frequency strings, please see `this link
529+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
524530
"""
525531
return ensure_compat('rolling',
526532
'quantile',
@@ -570,6 +576,9 @@ def rolling_apply(arg, window, func, min_periods=None, freq=None,
570576
The `freq` keyword is used to conform time series data to a specified
571577
frequency by resampling the data. This is done with the default parameters
572578
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
579+
580+
To learn more about the frequency strings, please see `this link
581+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
573582
"""
574583
return ensure_compat('rolling',
575584
'apply',
@@ -642,6 +651,9 @@ def rolling_window(arg, window=None, win_type=None, min_periods=None,
642651
The `freq` keyword is used to conform time series data to a specified
643652
frequency by resampling the data. This is done with the default parameters
644653
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
654+
655+
To learn more about the frequency strings, please see `this link
656+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
645657
"""
646658
func = 'mean' if mean else 'sum'
647659
return ensure_compat('rolling',
@@ -707,6 +719,9 @@ def expanding_count(arg, freq=None):
707719
The `freq` keyword is used to conform time series data to a specified
708720
frequency by resampling the data. This is done with the default parameters
709721
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
722+
723+
To learn more about the frequency strings, please see `this link
724+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
710725
"""
711726
return ensure_compat('expanding', 'count', arg, freq=freq)
712727

@@ -735,6 +750,9 @@ def expanding_quantile(arg, quantile, min_periods=1, freq=None):
735750
The `freq` keyword is used to conform time series data to a specified
736751
frequency by resampling the data. This is done with the default parameters
737752
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
753+
754+
To learn more about the frequency strings, please see `this link
755+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
738756
"""
739757
return ensure_compat('expanding',
740758
'quantile',
@@ -818,6 +836,9 @@ def expanding_apply(arg, func, min_periods=1, freq=None,
818836
The `freq` keyword is used to conform time series data to a specified
819837
frequency by resampling the data. This is done with the default parameters
820838
of :meth:`~pandas.Series.resample` (i.e. using the `mean`).
839+
840+
To learn more about the frequency strings, please see `this link
841+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
821842
"""
822843
return ensure_compat('expanding',
823844
'apply',

pandas/tseries/index.py

+12
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin,
189189
Attempt to infer fall dst-transition hours based on order
190190
name : object
191191
Name to be stored in the index
192+
193+
To learn more about the frequency strings, please see `this link
194+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
192195
"""
193196

194197
_typ = 'datetimeindex'
@@ -2026,6 +2029,9 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None,
20262029
-----
20272030
2 of start, end, or periods must be specified
20282031
2032+
To learn more about the frequency strings, please see `this link
2033+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
2034+
20292035
Returns
20302036
-------
20312037
rng : DatetimeIndex
@@ -2066,6 +2072,9 @@ def bdate_range(start=None, end=None, periods=None, freq='B', tz=None,
20662072
-----
20672073
2 of start, end, or periods must be specified
20682074
2075+
To learn more about the frequency strings, please see `this link
2076+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
2077+
20692078
Returns
20702079
-------
20712080
rng : DatetimeIndex
@@ -2117,6 +2126,9 @@ def cdate_range(start=None, end=None, periods=None, freq='C', tz=None,
21172126
-----
21182127
2 of start, end, or periods must be specified
21192128
2129+
To learn more about the frequency strings, please see `this link
2130+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
2131+
21202132
Returns
21212133
-------
21222134
rng : DatetimeIndex

pandas/tseries/tdi.py

+6
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index):
110110
the 'left', 'right', or both sides (None)
111111
name : object
112112
Name to be stored in the index
113+
114+
To learn more about the frequency strings, please see `this link
115+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
113116
"""
114117

115118
_typ = 'timedeltaindex'
@@ -1014,6 +1017,9 @@ def timedelta_range(start=None, end=None, periods=None, freq='D',
10141017
Returns
10151018
-------
10161019
rng : TimedeltaIndex
1020+
1021+
To learn more about the frequency strings, please see `this link
1022+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
10171023
"""
10181024
return TimedeltaIndex(start=start, end=end, periods=periods,
10191025
freq=freq, name=name,

0 commit comments

Comments
 (0)