From 1cff91eed3185f3e5d465ed64edffc72287eabe8 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Tue, 6 Jun 2023 00:00:07 +0200 Subject: [PATCH 1/3] DOC: table for period aliases --- doc/source/user_guide/timeseries.rst | 27 ++++++++++++++++++++++++++- pandas/core/arrays/datetimes.py | 8 ++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index 97be46e338c09..2c1cf35405418 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -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" + "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 ~~~~~~~~~~~~~~~~~ @@ -2083,7 +2108,7 @@ Period dtypes dtype similar to the :ref:`timezone aware dtype ` (``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 `. +``period[freq]`` like ``period[D]`` or ``period[M]``, using :ref:`frequency strings `. .. ipython:: python diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 28b56a220f005..4d76bf9835610 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1145,13 +1145,13 @@ def to_period(self, freq=None) -> PeriodArray: Parameters ---------- - freq : str or Offset, optional - One of pandas' :ref:`offset strings ` - or an Offset object. Will be inferred by default. + freq : str or Period, optional + One of pandas' :ref:`period strings ` + or an Period object. Will be inferred by default. Returns ------- - PeriodArray/Index + PeriodArray/PeriodIndex Raises ------ From 4dce2bc45abc7214dc84e5bcb83339e7edbeaa68 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Thu, 8 Jun 2023 13:50:32 +0200 Subject: [PATCH 2/3] correct the to_period docstrings --- pandas/core/arrays/datetimes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 4d76bf9835610..3d083e55b12ab 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1146,7 +1146,7 @@ def to_period(self, freq=None) -> PeriodArray: Parameters ---------- freq : str or Period, optional - One of pandas' :ref:`period strings ` + One of pandas' :ref:`period aliases ` or an Period object. Will be inferred by default. Returns From 46dde10cb34a4c69856bbe6c727aa3425b714617 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Fri, 9 Jun 2023 12:02:02 +0200 Subject: [PATCH 3/3] change quarter/year end to quarterly/yearly --- doc/source/user_guide/timeseries.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/user_guide/timeseries.rst b/doc/source/user_guide/timeseries.rst index 2c1cf35405418..fb1c37c1b9073 100644 --- a/doc/source/user_guide/timeseries.rst +++ b/doc/source/user_guide/timeseries.rst @@ -1315,8 +1315,8 @@ frequencies. We will refer to these aliases as *period aliases*. "D", "calendar day frequency" "W", "weekly frequency" "M", "monthly frequency" - "Q", "quarter end frequency" - "A, Y", "year end frequency" + "Q", "quarterly frequency" + "A, Y", "yearly frequency" "H", "hourly frequency" "T, min", "minutely frequency" "S", "secondly frequency"