-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
DEPR: Deprecate non-ISO date string formats in DatetimeIndex.loc #62991
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
base: main
Are you sure you want to change the base?
Changes from all commits
ccb5d50
7906b17
f3a1879
d12229d
8f84b2b
dcc5f93
467e1cb
d0ff888
2ac6b5b
3e16e12
5223f3f
ab4b56a
23ba779
936847d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,9 @@ def seed_df(seed_nans, n, m): | |
| @pytest.mark.parametrize("bins", [None, [0, 5]], ids=repr) | ||
| @pytest.mark.parametrize("isort", [True, False]) | ||
| @pytest.mark.parametrize("normalize, name", [(True, "proportion"), (False, "count")]) | ||
| @pytest.mark.filterwarnings( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this test need to filter warnings? It seems unrelated to the change?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we group by keys='2nd' (the date column - from parameterized tests), it triggers the deprecation warning internally during the groupby operation. Without it, those test cases fail in CI. So, added the filterwarnings. |
||
| "ignore:Parsing non-ISO datetime strings:pandas.errors.Pandas4Warning" | ||
| ) | ||
| def test_series_groupby_value_counts( | ||
| seed_nans, | ||
| num_rows, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Credit to @stefmolin for the original idea, but I don't think we should try and roll our own regex here if we can avoid it.
I see the standard library provides
date.fromisostring, although that is documented to not work with "Reduced Precision" dates:https://docs.python.org/3/library/datetime.html
Even still I wonder if we can't use that first and only fallback when it fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stefmolin @WillAyd!. Switched to using date.fromisoformat() like you suggested. Added a regex fallback to handle the reduced precision dates (YYYY and YYYY-MM) that fromisoformat doesn't support .