-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Timezones silently dropped in parsing #18702
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
hmm ok, I would rather hand off non-iso 8601 parsing to dateutil directly, so this would qualitfy. note that this only when format is not passed and in a very limited set of cases. |
I'd prefer that dateutil handle this internally too; my hope is that consensus will develop over there once more people report that it doesn't Just Work. But until then, it's still a nontrivial question of exactly what we want to recognize by default and whether/how to let users customize it. I see two viable options:
|
we shouldn’t be hard coding any time zones |
Can you expand on that? Are you suggesting users should do this before passing to Timestamp/to_datetime? |
of course not when parsing if u hit something that looks like a tz |
Good. That seemed unlikely (and altogether silly).
It's the "simply" that I'm having trouble with. here. This sounds like you're suggesting the parsing be done within pandas, which I thought was what we're trying to avoid. Can you give an example of what you have in mind? |
TLDR: pandas should pass a
tzinfos
kwarg to the dateutil parser using sensible defaults.dateutil has a bug that silently drops most timezones. That bug is inherited by pandas. The following is run on a machine located in US/Pacific:
There is a partial fix in progress over at dateutil, the most likely outcome of which is that these cases will raise in the future unless a
tzinfos
kwarg is explicitly passed todateutil.parser.parse
. The issue for pandas is then to decide on what tzinfos to pass (a suggestion to handle the most common use cases by default within dateutil went nowhere).The
tzinfos
kwarg is a dictionary taking a string and returning atzinfo
object, e.g.This example includes only abbreviations for which there are no other alternatives listed here. So e.g. "CST" is excluded since it could also be "China Standard Time", "EST" is excluded since it could refer to "Australian Eastern Standard Time". Note this is only a subset of the unambiguous abbreviations.
The text was updated successfully, but these errors were encountered: