Skip to content

DEPR: lower/uppercase strings such as 'y', 'q', 'H', 'MIN', etc. denoting freqs/units for time series, period, and timedelta #56346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c7d82ec
deprecate lowercase strings denoting freq for week, month, monthend, …
natmokval Dec 5, 2023
614710b
fix tests
natmokval Dec 5, 2023
458a9c1
fix tests
natmokval Dec 6, 2023
e9c8af5
correct def _get_offset, fix tests
natmokval Dec 7, 2023
73f68f0
add tests, fix tests
natmokval Dec 7, 2023
eea9b69
fix tests
natmokval Dec 11, 2023
386eb57
correct parse_timedelta_unit, to_offset, fix tests, add tests
natmokval Dec 11, 2023
5dcb918
resolve conflicts, fix tests, add tests
natmokval Dec 12, 2023
25bfbef
fix tests
natmokval Dec 12, 2023
eb418eb
resolve conflicts, depr 'MIN' from to_timedelta, fix tests
natmokval Dec 14, 2023
943b898
Merge branch 'main' into depr-uppercasing-in-get-offset
natmokval Dec 15, 2023
435db76
deprecate 'Min' in favour of 'min'
natmokval Dec 15, 2023
3cc94d2
correct docs
natmokval Dec 15, 2023
457ae96
show depr warning in test_construction() for Period
natmokval Dec 19, 2023
3837b7f
resolve conflict
natmokval Dec 19, 2023
f709557
correct warning message in test_construction()
natmokval Dec 20, 2023
7cd909f
remove from to_offset() unnecessary check, fix test_to_offset_invalid
natmokval Dec 20, 2023
8d1d6dd
fix pre-commit error
natmokval Dec 20, 2023
6c24541
Merge branch 'main' into depr-uppercasing-in-get-offset
natmokval Dec 20, 2023
286b618
add notes to /v2.2.0.rst
natmokval Dec 21, 2023
606d0c5
add filterwarnings to test_to_offset_invalid, correct notes in v2.2.0…
natmokval Dec 21, 2023
32993a9
improve the headline in v2.2.0.rst
natmokval Dec 21, 2023
dcf1994
correct depr note in v2.2.0.rst
natmokval Dec 21, 2023
5443b1e
Merge branch 'main' into depr-uppercasing-in-get-offset
natmokval Dec 21, 2023
7889c7d
correct to_offset() for freqs such us ys, qs, and add tests
natmokval Dec 27, 2023
00e80c0
Merge branch 'main' into depr-uppercasing-in-get-offset
natmokval Dec 27, 2023
0eb098e
resolve conflicts, fix tests
natmokval Jan 4, 2024
b6074b1
resolve conflicts
natmokval Feb 8, 2024
530f056
deprecate lowercase freq 'w', 'd' from timeseries
natmokval Feb 8, 2024
f600538
fix tests for 'D'
natmokval Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -408,21 +408,40 @@ For example:

pd.date_range('2020-01-01', periods=3, freq='QE-NOV')

Deprecate lowercase strings ``w``, ``m``, ``q``, etc. in favour of ``W``, ``M``, ``Q``, etc. for time series, period, and timedelta
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Deprecate lowercase strings ``w``, ``m``, ``q``, etc. and uppercase strings ``H``, ``MIN``, ``S``, etc. for time series, period, and timedelta
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Previously, both ``'h'`` and ``'H'`` would allowed for 'hour' offset/period alias. We now require the case to be correct - check the :ref:`offset aliases <timeseries.offset_aliases>` and the :ref:`period aliases <timeseries.period_aliases>` parts of the docs and make sure you're using the correct one (:issue:`56346`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"would allowed" -> "were allowed"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you, I corrected this.


Deprecated lowercase strings in favour of uppercase strings denoting:

Deprecated lowercase strings in favour of uppercase strings denoting (:issue:`56346`):
- period aliases weekly, monthly and bigger frequency
- offsets aliases representing :class:`DateOffset` subclasses that are a week or bigger (``Week``, ``MonthBegin``, ``MonthEnd``, etc.)
- timedelta units week, month or bigger
- timedelta units for week, month or bigger

Deprecate uppercase strings ``H`, ``S``, etc. in favour of ``h``, ``s``, etc. for time series, period, and timedelta
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Deprecated uppercase strings in favour of lowercase strings denoting:

Deprecated uppercase strings in favour of lowercase strings denoting (:issue:`56346`):
- period aliases hourly, minutely or smaller frequency
- offsets aliases representing :class:`DateOffset` subclasses that are an hour or smaller (``Hour``, ``Minute``, etc.)
- timedelta units hour, minute or smaller
- timedelta units for hour, minute or smaller

For example:

*Previous behavior*:

.. code-block:: ipython

In [9]: pd.date_range('2020-01-01', periods=3, freq='H')
Out[9]:
DatetimeIndex(['2020-01-01 00:00:00', '2020-01-01 01:00:00',
'2020-01-01 02:00:00'],
dtype='datetime64[ns]', freq='H')

*Future behavior*:

.. ipython:: python

pd.date_range('2020-01-01', periods=3, freq='h')

Deprecated automatic downcasting
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/tslibs/test_to_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ def test_to_offset_negative(freqstr, expected):
assert result.n == expected


@pytest.mark.filterwarnings(
"ignore:'m' is deprecated and will be removed in a future version.:FutureWarning"
)
@pytest.mark.parametrize(
"freqstr",
[
"2h20ME",
"2h20m",
"us1",
"-us",
"3us1",
Expand All @@ -64,7 +67,7 @@ def test_to_offset_negative(freqstr, expected):
"+1",
"-7",
"+d",
"-ME",
"-m",
# Invalid shortcut anchors.
"SME-0",
"SME-28",
Expand Down