Skip to content

Commit 35dca6f

Browse files
author
Chang She
committed
DOC: time_rule deprecation in sphinx docs for moving window functions #1042. Also started on new timeseries docs.
1 parent cf3167e commit 35dca6f

File tree

2 files changed

+112
-31
lines changed

2 files changed

+112
-31
lines changed

doc/source/computation.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ accept the following arguments:
171171
- ``window``: size of moving window
172172
- ``min_periods``: threshold of non-null data points to require (otherwise
173173
result is NA)
174-
- ``time_rule``: optionally specify a :ref:`time rule <timeseries.timerule>`
175-
to pre-conform the data to
174+
- ``freq``: optionally specify a :ref: `frequency string <timeseries.freq>` or :ref:`DateOffset <timeseries.offsets>`
175+
to pre-conform the data to. Note that prior to pandas v0.8.0, a keyword
176+
argument ``time_rule`` was used instead of ``freq`` that referred to
177+
the legacy time rule constants
176178

177179
These functions can be applied to ndarrays or Series objects:
178180

doc/source/timeseries.rst

+108-29
Original file line numberDiff line numberDiff line change
@@ -130,44 +130,123 @@ particular day of the week:
130130
d + Week(weekday=4)
131131
(d + Week(weekday=4)).weekday()
132132
133-
.. _timeseries.timerule:
133+
.. _timeseries.freq:
134134

135-
Time rules
136-
~~~~~~~~~~
135+
Offset Aliases
136+
~~~~~~~~~~~~~~
137137

138138
A number of string aliases are given to useful common time series
139-
frequencies. We will refer to these aliases as *time rules*.
139+
frequencies. We will refer to these aliases as *offset aliases*
140+
(referred to as *time rules* prior to v0.8.0).
140141

141142
.. csv-table::
142-
:header: "Rule name", "Description"
143+
:header: "Alias", "Description"
143144
:widths: 15, 65
144145

145-
"WEEKDAY", "business day frequency"
146-
"EOM", "business month end frequency"
147-
"W\@MON", "weekly frequency (mondays)"
148-
"W\@TUE", "weekly frequency (tuesdays)"
149-
"W\@WED", "weekly frequency (wednesdays)"
150-
"W\@THU", "weekly frequency (thursdays)"
151-
"W\@FRI", "weekly frequency (fridays)"
152-
"Q\@JAN", "quarterly frequency, starting January"
153-
"Q\@FEB", "quarterly frequency, starting February"
154-
"Q\@MAR", "quarterly frequency, starting March"
155-
"A\@DEC", "annual frequency, year end (December)"
156-
"A\@JAN", "annual frequency, anchored end of January"
157-
"A\@FEB", "annual frequency, anchored end of February"
158-
"A\@MAR", "annual frequency, anchored end of March"
159-
"A\@APR", "annual frequency, anchored end of April"
160-
"A\@MAY", "annual frequency, anchored end of May"
161-
"A\@JUN", "annual frequency, anchored end of June"
162-
"A\@JUL", "annual frequency, anchored end of July"
163-
"A\@AUG", "annual frequency, anchored end of August"
164-
"A\@SEP", "annual frequency, anchored end of September"
165-
"A\@OCT", "annual frequency, anchored end of October"
166-
"A\@NOV", "annual frequency, anchored end of November"
167-
168-
These can be used as arguments to ``DateRange`` and various other time
146+
"B", "business day frequency"
147+
"D", "calendar day frequency"
148+
"W", "weekly frequency"
149+
"M", "month end frequency"
150+
"BM", "business month end frequency"
151+
"MS", "month start frequency"
152+
"BMS", "business month start frequency"
153+
"Q", "quarter end frequency"
154+
"BQ", "business quarter endfrequency"
155+
"QS", "quarter start frequency"
156+
"BQS", "business quarter start frequency"
157+
"A", "year end frequency"
158+
"BA", "business year end frequency"
159+
"AS", "year start frequency"
160+
"BAS", "business year start frequency"
161+
"H", "hourly frequency"
162+
"T", "minutely frequency"
163+
"S", "secondly frequency"
164+
"L", "milliseonds"
165+
"U", "microseconds"
166+
167+
For some frequencies you can specify an anchoring suffix:
168+
169+
.. csv-table::
170+
:header: "Alias", "Description"
171+
:widths: 15, 65
172+
173+
"W\-SUN", "weekly frequency (sundays). Same as 'W'"
174+
"W\-MON", "weekly frequency (mondays)"
175+
"W\-TUE", "weekly frequency (tuesdays)"
176+
"W\-WED", "weekly frequency (wednesdays)"
177+
"W\-THU", "weekly frequency (thursdays)"
178+
"W\-FRI", "weekly frequency (fridays)"
179+
"W\-SAT", "weekly frequency (saturdays)"
180+
"(B)Q(S)\-DEC", "quarterly frequency, year ends in December. Same as 'Q'"
181+
"(B)Q(S)\-JAN", "quarterly frequency, year ends in January"
182+
"(B)Q(S)\-FEB", "quarterly frequency, year ends in February"
183+
"(B)Q(S)\-MAR", "quarterly frequency, year ends in March"
184+
"(B)Q(S)\-APR", "quarterly frequency, year ends in April"
185+
"(B)Q(S)\-MAY", "quarterly frequency, year ends in May"
186+
"(B)Q(S)\-JUN", "quarterly frequency, year ends in June"
187+
"(B)Q(S)\-JUL", "quarterly frequency, year ends in July"
188+
"(B)Q(S)\-AUG", "quarterly frequency, year ends in August"
189+
"(B)Q(S)\-SEP", "quarterly frequency, year ends in September"
190+
"(B)Q(S)\-OCT", "quarterly frequency, year ends in October"
191+
"(B)Q(S)\-NOV", "quarterly frequency, year ends in November"
192+
"(B)A(S)\-DEC", "annual frequency, anchored end of December. Same as 'A'"
193+
"(B)A(S)\-JAN", "annual frequency, anchored end of January"
194+
"(B)A(S)\-FEB", "annual frequency, anchored end of February"
195+
"(B)A(S)\-MAR", "annual frequency, anchored end of March"
196+
"(B)A(S)\-APR", "annual frequency, anchored end of April"
197+
"(B)A(S)\-MAY", "annual frequency, anchored end of May"
198+
"(B)A(S)\-JUN", "annual frequency, anchored end of June"
199+
"(B)A(S)\-JUL", "annual frequency, anchored end of July"
200+
"(B)A(S)\-AUG", "annual frequency, anchored end of August"
201+
"(B)A(S)\-SEP", "annual frequency, anchored end of September"
202+
"(B)A(S)\-OCT", "annual frequency, anchored end of October"
203+
"(B)A(S)\-NOV", "annual frequency, anchored end of November"
204+
205+
These can be used as arguments to ``date_range``, ``period_range``, constructors
206+
for ``PeriodIndex`` and ``DatetimeIndex``, as well as various other time
169207
series-related functions in pandas.
170208

209+
Note that prior to v0.8.0, time rules had a slightly different look. Pandas
210+
will continue to support the legacy time rules for the time being but it is
211+
strongly recommended that you switch to using the new offset aliases.
212+
213+
.. csv-table::
214+
:header: "Legacy Time Rule", "Offset Alias"
215+
:widths: 15, 15
216+
217+
"WEEKDAY", "B"
218+
"EOM", "BM"
219+
"W\@MON", "W\-MON"
220+
"W\@TUE", "W\-TUE"
221+
"W\@WED", "W\-WED"
222+
"W\@THU", "W\-THU"
223+
"W\@FRI", "W\-FRI"
224+
"W\@SAT", "W\-SAT"
225+
"W\@SUN", "W\-SUN"
226+
"Q\@JAN", "BQ\-JAN"
227+
"Q\@FEB", "BQ\-FEB"
228+
"Q\@MAR", "BQ\-MAR"
229+
"A\@JAN", "BA\-JAN"
230+
"A\@FEB", "BA\-FEB"
231+
"A\@MAR", "BA\-MAR"
232+
"A\@APR", "BA\-APR"
233+
"A\@MAY", "BA\-MAY"
234+
"A\@JUN", "BA\-JUN"
235+
"A\@JUL", "BA\-JUL"
236+
"A\@AUG", "BA\-AUG"
237+
"A\@SEP", "BA\-SEP"
238+
"A\@OCT", "BA\-OCT"
239+
"A\@NOV", "BA\-NOV"
240+
"A\@DEC", "BA\-DEC"
241+
"min", "T"
242+
"ms", "L"
243+
"us": "U"
244+
245+
Note that the legacy quarterly and annual frequencies are business quarter and
246+
business year ends. Also note the legacy time rule for milliseconds ``ms``
247+
versus the new offset alias for month start ``MS``. This means that offset
248+
alias parsing is case sensitive.
249+
171250
.. _timeseries.daterange:
172251

173252
Generating date ranges (DateRange)

0 commit comments

Comments
 (0)