Skip to content

DOC: create a table for period aliases #53530

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

Merged
merged 6 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
27 changes: 26 additions & 1 deletion doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,31 @@ frequencies. We will refer to these aliases as *offset aliases*.
given frequency it will roll to the next value for ``start_date``
(respectively previous for the ``end_date``)

.. _timeseries.period_aliases:

Period aliases
~~~~~~~~~~~~~~

A number of string aliases are given to useful common time series
frequencies. We will refer to these aliases as *period aliases*.

.. csv-table::
:header: "Alias", "Description"
:widths: 15, 100

"B", "business day frequency"
"D", "calendar day frequency"
"W", "weekly frequency"
"M", "monthly frequency"
"Q", "quarter end frequency"
Copy link
Member

Choose a reason for hiding this comment

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

Wait, for period there is no "end", should this be "quarter frequency"?

Copy link
Contributor Author

@natmokval natmokval Jun 9, 2023

Choose a reason for hiding this comment

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

Oops, my mistake. I'll correct it.

Update:
to keep all frequencies in a similar style I changed quarter end to quarterly. The same for year end frequency.

"A, Y", "year end frequency"
"H", "hourly frequency"
"T, min", "minutely frequency"
"S", "secondly frequency"
"L, ms", "milliseconds"
"U, us", "microseconds"
"N", "nanoseconds"


Combining aliases
~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -2083,7 +2108,7 @@ Period dtypes
dtype similar to the :ref:`timezone aware dtype <timeseries.timezone_series>` (``datetime64[ns, tz]``).

The ``period`` dtype holds the ``freq`` attribute and is represented with
``period[freq]`` like ``period[D]`` or ``period[M]``, using :ref:`frequency strings <timeseries.offset_aliases>`.
``period[freq]`` like ``period[D]`` or ``period[M]``, using :ref:`frequency strings <timeseries.period_aliases>`.

.. ipython:: python

Expand Down
8 changes: 4 additions & 4 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,13 +1145,13 @@ def to_period(self, freq=None) -> PeriodArray:
Parameters
----------
freq : str or Offset, optional
One of pandas' :ref:`offset strings <timeseries.offset_aliases>`
or an Offset object. Will be inferred by default.
freq : str or Period, optional
One of pandas' :ref:`period aliases <timeseries.period_aliases>`
or an Period object. Will be inferred by default.
Returns
-------
PeriodArray/Index
PeriodArray/PeriodIndex
Raises
------
Expand Down