-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Datetime parsing (PDEP-4): should those changes apply to DatetimeIndex(strings) as well? #50894
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
Comments
Another note: I am writing this issue naively from observing the user behaviour. I am not very up to date on how DatetimeIndex(..) string parsing is implemented, and to what extent it has separate code paths for the actual parsing compared to |
@jbrockmendel brought up the good point that there are some inconsistencies in keywords / capabilities between
This might make it harder to change DatetimeIndex (i.e. also make its string parsing strict), as it doesn't have the |
removing the 2.0 milestone, but there's plenty of scope to take pdep4 further for 3.0 and beyond |
Moving this from #50411 (comment) to its own issue.
PDEP-4 (http://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html) has made the string->datetime parsing stricter. For example, using the example from the PDEP on the latest main branch:
The above parses fine on pandas < 2, but parses both strings differently (month first vs day first), and so with latest pandas the above now raises an error.
But if I pass those strings to the
DatetimeIndex(..)
constructor, we still happily parse this inconsistently:I don't think this was discussed in the PDEP discussion, but if we are changing this, shouldn't we make the parsing in DatetimeIndex consistent as well?
(sidenote: long term might want to make parsing in DatetimeIndex even stricter, as brought up in #50411 (comment) and comments below, eg only accepting ISO strings, or not even accepting strings at all, since you can use
to_datetime
instead. But let's leave that discussion for a separate thread, since that's something that can be deprecated, and not necessary for 2.0)cc @MarcoGorelli
The text was updated successfully, but these errors were encountered: