Skip to content
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

DEPR: lowercase freqs 'ye', 'qe', etc. raise a ValueError #56910

Merged

Conversation

natmokval
Copy link
Contributor

@natmokval natmokval commented Jan 16, 2024

xref #56346, #56847, #9586

Using lowercase frequencies such as ‘y’, ‘ye’, ‘q’, ‘qe’, etc. raise aValueError on main, though it worked before. Using those was never documented, but if people are use these lowercase frequencies, we should keep them work.

For example:

>>> pd.period_range("2020-01-01", "2020-08-01", freq="y")
ValueError: Invalid frequency: y, failed to parse with error message: ValueError("Invalid frequency: Y, failed to parse with error message: KeyError('Y')")
>>> pd.date_range("1/1/2000", periods=4, freq="qe")
ValueError: Invalid frequency: qe, failed to parse with error message: ValueError("Invalid frequency: qe, failed to parse with error message: KeyError('qe')")

The definition of to_offset is corrected, so now we can see the FutureWarning.

>>> pd.period_range("2020-01-01", "2020-08-01", freq="y")
<stdin>:1: FutureWarning: 'y' is deprecated and will be removed in a future version, please use 'Y' instead.
PeriodIndex(['2020'], dtype='period[Y-DEC]')
>>> pd.date_range("1/1/2000", periods=4, freq="qe")
<stdin>:1: FutureWarning: 'qe' is deprecated and will be removed in a future version, please use 'QE' instead.
DatetimeIndex(['2000-03-31', '2000-06-30', '2000-09-30', '2000-12-31'], dtype='datetime64[ns]', freq='QE-DEC')

@natmokval natmokval marked this pull request as ready for review January 16, 2024 15:41
@natmokval natmokval added Deprecate Functionality to remove in pandas Frequency DateOffsets labels Jan 16, 2024
@natmokval
Copy link
Contributor Author

@MarcoGorelli, could you please take a look at this PR?

@MarcoGorelli MarcoGorelli added this to the 2.2 milestone Jan 17, 2024
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Just in time - well done for spotting this and fixing it so close to the release!

Looking forwards to enforcing these deprecations so that all this complexity can be reduced

Nice one @natmokval !

@MarcoGorelli MarcoGorelli merged commit 02011f2 into pandas-dev:main Jan 17, 2024
50 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 17, 2024
MarcoGorelli pushed a commit that referenced this pull request Jan 17, 2024
… etc. raise a ValueError) (#56924)

Backport PR #56910: DEPR: lowercase freqs 'ye', 'qe', etc. raise a ValueError

Co-authored-by: Natalia Mokeeva <91160475+natmokval@users.noreply.github.com>
@natmokval
Copy link
Contributor Author

Thank you for reviewing this PR!

@lithomas1
Copy link
Member

@MarcoGorelli is this scheduled for removal in 4.0?

you might need to manually move the deprecation bullet from the 4.0 tracker issue to the 3.0 tracker issue if it isn't.

@MarcoGorelli
Copy link
Member

thanks, will do

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…#56910)

* correct dict _dont_uppercase, def to_offset, fix test

* fix tests, add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants