-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Timestamp.tz_localize() NonExistentTimeError handling #8917
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
|
@mskrajnowski I have been thinking about this more and wonder if your data is really in a standard time zone and you should be localizing to that and then converting. For example, what does the data look like for that Spring DST change day? Are there 24 hours or just 23? Maybe the localizing issue is masking something else. |
It seems to me that the only overlap between the sorts of options that make sense for handling ambiguous times and the options that make sense for nonexistent times are
How do these match up against the options for ambiguous time handling? Does the knob for nonexistent time handling need to be separate from the one for ambiguous times? |
@rockg I'm implementing a scheduling application. The user defines working hours in his/her own timezone, then I'm combining the time provided by the user with dates, to get actual work start and end utc datetimes. I can't really forbid the user from setting 02:30 as his work start/end time (maybe he/she likes to wake up in the middle of the night and code ;) ), so I need a way to reliably localize any datetime. Even if technically a given time doesn't exist, I still need to output some logical utc datetime. @ischwabacher I'd go with the way |
Unfortunately, One issue I have here is that Also, if your users set a time of 2:30 as a work start/end time, do you think your users will be least surprised by an alarm at 1:30, 3:00, or 3:30? Does it depend on whether it's a start or end time? |
Since 2:00 becomes 3:00 in that transition, imho it's logical that 2:30 would become 3:30. That's what I get with |
Another thing that would help is if we had an api which would enable us to fix ambiguous and non existent times. Maybe tz_localize could return NaT along with information, why a time wasn't localized? If I had such information, I could, for example , add an hour to non existent times and retry. At the moment tz_localize raises on first error, which isn't very helpful when working with series. |
I definitely think there should be an option to return As far as defaults go, I think we should keep |
Hi guys - Was this released in 0.20.2 yet? I'm seeing the same problem here. |
This issue is still open, so no, this has not been fixed in 0.20.2. Contributions are welcome. |
@jorisvandenbossche @esvhd same problem here. Got some timestamps in central time, and try to localize in EST give me this error. Is there a quick and dirty fix for that? Thanks! |
There should be nothing wrong converting to EST as that does not have DST offsets. Can you post your example?
|
@rockg No I mean I convert from Central time to EST.
|
@jorisvandenbossche @mskrajnowski @rockg would this be the Assume
|
@jorisvandenbossche @mskrajnowski @rockg any ideas? sorry for the spam but this is an important question in my humble opinion :D |
I'm trying to use pandas to speed up timezone conversions on many datetimes and I can't get around
NonExistentTimeErrors
. Pandastz_localize()
seems to ignore theambiguous
argument for the non existent time case.Example:
It would be nice if the
ambiguous
argument worked the same asis_dst
in pytz. As it is now, it's impossible afaik to reliably localize a series of datetimes using pandas, since any of them might cause aNonExistentTimeError
and there's no way of guiding pandas what to do with such datetimes.The text was updated successfully, but these errors were encountered: