-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: disallow tznaive datetimes when indexing tzaware datetimeindex #36148
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: disallow tznaive datetimes when indexing tzaware datetimeindex #36148
Conversation
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.
IIRC there is an issue about this, and we had quite some discussion. I am +1 on actually doing this, but we might need to deprecate first. cc @jorisvandenbossche @TomAugspurger
+1 on doing this too. It would be great to do this for tz-naive datelike-strings as well. |
The discussion 2ish years ago ended up deciding to special-case naive strings because a) user convenience and b) there's not a nice way to specify a tz in a string for e.g. "US/Eastern". IIRC the consensus was pretty specifically strings only, and the fact that we currently allow mismatched datetime/timestamp objects is the bug. |
A more recent discussion about this is in #30994 (I think this PR is meant to address that issue?)
Yes, I think that is correct.
What do you mean exactly with "mismatched datetime/timestamp objects" (just the fact of tz-naive vs tz-aware)? |
…i-get_loc-awareness-2
@jorisvandenbossche so i have a way forward, is your suggestion that the two
If so, is everyone else on board with that? FWIW i think this behavior is sufficiently inconsistent we should call it a bugfix and be done with it, but I'm OK with deprecating if there's a consensus. |
+1 on this. note we are deprecating for strings AND timestamps correct? (I think we should) |
the discussion so far has been about changing/deprecating the incorrect timestamp behavior, not about undoing the special-casing for strings |
…i-get_loc-awareness-2
…i-get_loc-awareness-2
updated as deprecation (though i still think this should be considered a bugfix) |
lgtm, just resolved the conflict. |
…i-get_loc-awareness-2
…das into dti-get_loc-awareness-2
lgtm merge on green. |
…i-get_loc-awareness-2
…das into dti-get_loc-awareness-2
…andas-dev#36148) * BUG: allowing tznaive datetimes when indexing tzaware datetimeindex * isort fixup * deprecate wrong behavior * whatsnew Co-authored-by: Jeff Reback <[email protected]>
@jbrockmendel Should this be checked for insert too? Currently we are raising a FutureWarning for allow_duplicates=False because we run into If this should raise I would either change the order of the calls here or explicitly check for the mismatch. If you remove this line, no warning is raised |
So there's a case where frame.columns is tzaware and the user is doing frame.insert(int, tznaive_datetime, value)? The (or maybe a more specific warning?) |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
cc @mroeschke