From 0fb6f5ceb07665ae61f62eab37aa8e05aed78bfb Mon Sep 17 00:00:00 2001 From: Daniel Saxton Date: Wed, 24 Jun 2020 18:06:17 -0500 Subject: [PATCH 1/3] ERR: Fix to_timedelta error message --- pandas/core/tools/timedeltas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/tools/timedeltas.py b/pandas/core/tools/timedeltas.py index a643c312ec358..e457a8819f27a 100644 --- a/pandas/core/tools/timedeltas.py +++ b/pandas/core/tools/timedeltas.py @@ -94,7 +94,7 @@ def to_timedelta(arg, unit=None, errors="raise"): if unit in {"Y", "y", "M"}: raise ValueError( - "Units 'M' and 'Y' are no longer supported, as they do not " + "Units 'M', 'Y', and 'y' are no longer supported, as they do not " "represent unambiguous timedelta values durations." ) From d35b0fc5133ecc2d5c3e1a9310a19cc9ba14f665 Mon Sep 17 00:00:00 2001 From: Daniel Saxton Date: Wed, 24 Jun 2020 18:48:42 -0500 Subject: [PATCH 2/3] Fix --- pandas/_libs/tslibs/timedeltas.pyx | 2 +- pandas/core/indexes/timedeltas.py | 2 +- pandas/tests/scalar/timedelta/test_timedelta.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 1c3e69e21aa18..2862e62e3d522 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1151,7 +1151,7 @@ class Timedelta(_Timedelta): if unit in {'Y', 'y', 'M'}: raise ValueError( - "Units 'M' and 'Y' are no longer supported, as they do not " + "Units 'M', 'Y', and 'y' are no longer supported, as they do not " "represent unambiguous timedelta values durations." ) diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index f6661c6b50dfb..dccc8369c5366 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -136,7 +136,7 @@ def __new__( if unit in {"Y", "y", "M"}: raise ValueError( - "Units 'M' and 'Y' are no longer supported, as they do not " + "Units 'M', 'Y', and 'y' are no longer supported, as they do not " "represent unambiguous timedelta values durations." ) diff --git a/pandas/tests/scalar/timedelta/test_timedelta.py b/pandas/tests/scalar/timedelta/test_timedelta.py index 38e77321418d1..a01921bd6c4c2 100644 --- a/pandas/tests/scalar/timedelta/test_timedelta.py +++ b/pandas/tests/scalar/timedelta/test_timedelta.py @@ -265,7 +265,7 @@ def test_unit_parser(self, units, np_unit, wrapper): @pytest.mark.parametrize("unit", ["Y", "y", "M"]) def test_unit_m_y_raises(self, unit): - msg = "Units 'M' and 'Y' are no longer supported" + msg = "Units 'M', 'Y', and 'y' are no longer supported" with pytest.raises(ValueError, match=msg): Timedelta(10, unit) From 201949d60b3b571572e08eed5f8f91d6cce485a2 Mon Sep 17 00:00:00 2001 From: Daniel Saxton Date: Wed, 24 Jun 2020 19:11:38 -0500 Subject: [PATCH 3/3] Test --- pandas/tests/indexes/timedeltas/test_constructors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexes/timedeltas/test_constructors.py b/pandas/tests/indexes/timedeltas/test_constructors.py index acc68dfe7301f..41e4e220c999c 100644 --- a/pandas/tests/indexes/timedeltas/test_constructors.py +++ b/pandas/tests/indexes/timedeltas/test_constructors.py @@ -12,7 +12,7 @@ class TestTimedeltaIndex: @pytest.mark.parametrize("unit", ["Y", "y", "M"]) def test_unit_m_y_raises(self, unit): - msg = "Units 'M' and 'Y' are no longer supported" + msg = "Units 'M', 'Y', and 'y' are no longer supported" with pytest.raises(ValueError, match=msg): TimedeltaIndex([1, 3, 7], unit)