From fc1d9d88bb0a6d83c46d89053f441fd26469bece Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 30 Jan 2025 13:03:38 +0100 Subject: [PATCH 1/5] test_datetimes.py: fix literal string --- pandas/tests/arrays/test_datetimes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/arrays/test_datetimes.py b/pandas/tests/arrays/test_datetimes.py index e3f49d04a0ff2..d703a868bd6f8 100644 --- a/pandas/tests/arrays/test_datetimes.py +++ b/pandas/tests/arrays/test_datetimes.py @@ -769,8 +769,10 @@ def test_date_range_frequency_M_Q_Y_raises(self, freq): @pytest.mark.parametrize("freq_depr", ["2MIN", "2nS", "2Us"]) def test_date_range_uppercase_frequency_deprecated(self, freq_depr): # GH#9586, GH#54939 - depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a " - f"future version. Please use '{freq_depr.lower()[1:]}' instead." + depr_msg = ( + f"'{freq_depr[1:]}' is deprecated and will be removed in a " + f"future version. Please use '{freq_depr.lower()[1:]}' instead." + ) expected = pd.date_range("1/1/2000", periods=4, freq=freq_depr.lower()) with tm.assert_produces_warning(FutureWarning, match=depr_msg): From a2e43adc9efe12724c002a660fe9732a8ab7abe6 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 30 Jan 2025 13:24:38 +0100 Subject: [PATCH 2/5] fix test --- pandas/tests/arrays/test_datetimes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arrays/test_datetimes.py b/pandas/tests/arrays/test_datetimes.py index d703a868bd6f8..87505b1b22fc4 100644 --- a/pandas/tests/arrays/test_datetimes.py +++ b/pandas/tests/arrays/test_datetimes.py @@ -771,7 +771,7 @@ def test_date_range_uppercase_frequency_deprecated(self, freq_depr): # GH#9586, GH#54939 depr_msg = ( f"'{freq_depr[1:]}' is deprecated and will be removed in a " - f"future version. Please use '{freq_depr.lower()[1:]}' instead." + f"future version, please use '{freq_depr.lower()[1:]}' instead." ) expected = pd.date_range("1/1/2000", periods=4, freq=freq_depr.lower()) From 211429ab8586dd51531adf26ab2a6905c9271d8a Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 30 Jan 2025 14:16:44 +0100 Subject: [PATCH 3/5] fix repeated whitespace --- pandas/_libs/tslibs/offsets.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 36b431974c121..c2090b92bf80e 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -4883,7 +4883,7 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\' " + f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\'" f" instead.", FutureWarning, stacklevel=find_stack_level(), @@ -4897,7 +4897,7 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{_name}\' " + f"\'{_name}\'" f" instead.", FutureWarning, stacklevel=find_stack_level(), From 25709a4bea7891ceb5ab09b1ea807baa927e1567 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 31 Jan 2025 10:15:04 +0100 Subject: [PATCH 4/5] add whatsnew entry --- doc/source/whatsnew/v3.0.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index a7f63d75a047e..cd93112e4c3fe 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -73,6 +73,7 @@ Other enhancements - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) - Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`) +- Improved deprecation message for offset aliases (:issue:`60820`) .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: From 2fc2e296f575059523d3618e13cbf626ccb42a9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:24:22 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/source/whatsnew/v3.0.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index cd93112e4c3fe..361bd0b84dbb8 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -68,12 +68,12 @@ Other enhancements - :meth:`Series.str.get_dummies` now accepts a ``dtype`` parameter to specify the dtype of the resulting DataFrame (:issue:`47872`) - :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`) - Implemented :meth:`Series.str.isascii` and :meth:`Series.str.isascii` (:issue:`59091`) +- Improved deprecation message for offset aliases (:issue:`60820`) - Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`) - Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`) - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) - Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`) -- Improved deprecation message for offset aliases (:issue:`60820`) .. --------------------------------------------------------------------------- .. _whatsnew_300.notable_bug_fixes: