diff --git a/doc/source/whatsnew/v2.2.0.rst b/doc/source/whatsnew/v2.2.0.rst index 16d279bb0d52c..e29abad449498 100644 --- a/doc/source/whatsnew/v2.2.0.rst +++ b/doc/source/whatsnew/v2.2.0.rst @@ -211,8 +211,8 @@ Other API changes Deprecations ~~~~~~~~~~~~ -Deprecate aliases ``M`` and ``Q`` in favour of ``ME`` and ``QE`` for offsets -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Deprecate aliases ``M``, ``Q``, and ``Y`` in favour of ``ME``, ``QE``, and ``YE`` for offsets +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The alias ``M`` is deprecated in favour of ``ME`` for offsets, please use ``ME`` for "month end" instead of ``M`` (:issue:`9586`) @@ -252,6 +252,25 @@ For example: pd.date_range('2020-01-01', periods=3, freq='QE-NOV') +The alias ``Y`` is deprecated in favour of ``YE`` for offsets, please use ``YE`` for "year end" instead of ``Y`` (:issue:`9586`) + +For example: + +*Previous behavior*: + +.. code-block:: ipython + + In [9]: pd.date_range('2020-01-01', periods=3, freq='Y-MAR') + Out[9]: + DatetimeIndex(['2020-03-31', '2021-03-31', '2022-03-31'], + dtype='datetime64[ns]', freq='YE-MAR') + +*Future behavior*: + +.. ipython:: python + + pd.date_range('2020-01-01', periods=3, freq='YE-MAR') + Other Deprecations ^^^^^^^^^^^^^^^^^^ - Changed :meth:`Timedelta.resolution_string` to return ``h``, ``min``, ``s``, ``ms``, ``us``, and ``ns`` instead of ``H``, ``T``, ``S``, ``L``, ``U``, and ``N``, for compatibility with respective deprecations in frequency aliases (:issue:`52536`) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index be4b1b7fb6501..540e041604075 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1513,7 +1513,7 @@ def isocalendar(self) -> DataFrame: year = _field_accessor( "year", - "YE", + "Y", """ The year of the datetime. @@ -1536,7 +1536,7 @@ def isocalendar(self) -> DataFrame: ) month = _field_accessor( "month", - "ME", + "M", """ The month as January=1, December=12.