From b149d25348a3fa1fa7f0cbf87bfe504cf0201f4e Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Thu, 14 Dec 2023 22:19:54 +0100 Subject: [PATCH 1/3] remove redundant entries from _lite_rule_alias --- pandas/_libs/tslibs/offsets.pyx | 7 +++---- pandas/tests/scalar/period/test_period.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index b893939969c68..71807a93e8078 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -4644,10 +4644,6 @@ _lite_rule_alias = { "BYS": "BYS-JAN", # BYearBegin(month=1), "Min": "min", - "min": "min", - "ms": "ms", - "us": "us", - "ns": "ns", } _dont_uppercase = { @@ -4672,6 +4668,9 @@ _dont_uppercase = { "qe-oct", "qe-nov", "ye", + "min", + "ns", + "us", } diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index aa4a8b152b19f..3784718a291dd 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -106,7 +106,7 @@ def test_construction(self): assert i1 == i3 i1 = Period("1982", freq="min") - i2 = Period("1982", freq="MIN") + i2 = Period("1982", freq="Min") assert i1 == i2 i1 = Period(year=2005, month=3, day=1, freq="D") From df6811529c29789943e6537405db1b3f656e93d9 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Fri, 15 Dec 2023 13:36:43 +0100 Subject: [PATCH 2/3] fix test --- pandas/tests/indexes/datetimes/test_partial_slicing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexes/datetimes/test_partial_slicing.py b/pandas/tests/indexes/datetimes/test_partial_slicing.py index 0ebb88afb6c86..8b493fc61cb58 100644 --- a/pandas/tests/indexes/datetimes/test_partial_slicing.py +++ b/pandas/tests/indexes/datetimes/test_partial_slicing.py @@ -236,7 +236,7 @@ def test_partial_slice_second_precision(self): rng = date_range( start=datetime(2005, 1, 1, 0, 0, 59, microsecond=999990), periods=20, - freq="US", + freq="us", ) s = Series(np.arange(20), rng) From e518042481870a135ab04e67963d41e42636a965 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Thu, 18 Jul 2024 10:35:50 +0200 Subject: [PATCH 3/3] add US, NS to c_PERIOD_AND_OFFSET_DEPR_FREQSTR, fix tests --- pandas/_libs/tslibs/dtypes.pyx | 2 ++ pandas/_libs/tslibs/offsets.pyx | 11 ++++++++--- pandas/tests/arrays/test_datetimes.py | 2 +- pandas/tests/tslibs/test_to_offset.py | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pandas/_libs/tslibs/dtypes.pyx b/pandas/_libs/tslibs/dtypes.pyx index 7e6e382c17cc6..4100f3d90e817 100644 --- a/pandas/_libs/tslibs/dtypes.pyx +++ b/pandas/_libs/tslibs/dtypes.pyx @@ -359,6 +359,8 @@ cdef dict c_PERIOD_AND_OFFSET_DEPR_FREQSTR = { "b": "B", "c": "C", "MIN": "min", + "US": "us", + "NS": "ns", } cdef str INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}" diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 4ae101d169e01..5b913a3ccdea1 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -4695,11 +4695,16 @@ _lite_rule_alias = { "YS": "YS-JAN", # YearBegin(month=1), "BYE": "BYE-DEC", # BYearEnd(month=12), "BYS": "BYS-JAN", # BYearBegin(month=1), - - "Min": "min", } -_dont_uppercase = {"h", "bh", "cbh", "MS", "ms", "s"} +_dont_uppercase = { + "h", + "bh", + "cbh", + "MS", + "ms", + "s", +} INVALID_FREQ_ERR_MSG = "Invalid frequency: {0}" diff --git a/pandas/tests/arrays/test_datetimes.py b/pandas/tests/arrays/test_datetimes.py index de189b7e2f724..1e67acc22c486 100644 --- a/pandas/tests/arrays/test_datetimes.py +++ b/pandas/tests/arrays/test_datetimes.py @@ -760,7 +760,7 @@ def test_date_range_frequency_M_Q_Y_raises(self, freq): with pytest.raises(ValueError, match=msg): pd.date_range("1/1/2000", periods=4, freq=freq) - @pytest.mark.parametrize("freq_depr", ["2MIN", "2mS", "2Us"]) + @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 " diff --git a/pandas/tests/tslibs/test_to_offset.py b/pandas/tests/tslibs/test_to_offset.py index 67521c7e2a3ac..569c7af3045df 100644 --- a/pandas/tests/tslibs/test_to_offset.py +++ b/pandas/tests/tslibs/test_to_offset.py @@ -204,7 +204,7 @@ def test_to_offset_lowercase_frequency_raises(freq_depr): to_offset(freq_depr) -@pytest.mark.parametrize("freq_depr", ["2MIN", "2Us", "2NS"]) +@pytest.mark.parametrize("freq_depr", ["2MIN", "2US", "2NS"]) def test_to_offset_uppercase_frequency_deprecated(freq_depr): # GH#54939 depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "