-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Timezones and Datetime64 #3290
Comments
If we're naive, shouldn't we also refuse to process a timezone offset of 0, "Naive" and "UTC" are different timezones... note that these return On Mon, Apr 29, 2013 at 5:54 PM, Christopher H.Barker, PhD <
|
Well, dateutil returns a time-zone aware datetime object when you give it a time zone -- so it CAN return different values with and without a TZ offset. I just figured it wouldn't change the value, so why not. But sure, perhaps it would be less likely to cause errors later on to not except ANY timezone offset in a ISO string. |
I mean that it is a different value precisely in the sense that time-zone In [6]: dateutil.parser.parse("2010-01-01T00:00:00") In [7]: dateutil.parser.parse("2010-01-01T00:00:00Z") In [8]: dateutil.parser.parse("2010-01-01T00:00:00") - Saying "oh well they're not that different it might be convenient and who On Tue, Apr 30, 2013 at 12:33 AM, Christopher H.Barker, PhD <
|
@wesm: Do you have any opinion on the proposed changes? I'm extremely On Tue, Apr 30, 2013 at 8:18 AM, Nathaniel Smith njs@pobox.com wrote:
|
@njsmith , Yes. Naive and Tz-aware date times are quite different. But doing tz-awareness right is really hard. Even if we can Agree on what we want it to do. This my proposal to stick with naive. Which, indeed it currently is--the current code simply uses some unfortunate defaults. I'd like to see that change to something far more useful. If we go with naive, then really the only open question is when to raise errors when parsing ISO strings. If numpy only supports naive date times, then I see little chance of confusion if it accepts a tzoffset of 0 -- but consistancy is good, so no- offset-allowed is good too. |
I think that
The |
I should also add that unfortunately we had to kind of do everything ourselves in pandas because the NumPy datetime64 stuff has been in flux (I wrote earlier "mess" but that was putting it a bit strongly, sorry). I also disagreed with some of the decisions that Mark made in the API. I think interpreting a timestamp as naive and not localtime is a good idea, I didn't like the "convert this naive string to UTC given local timezone" which is how I recall numpy 1.7 working |
@mwiebe Just a heads up to the discussion on the datetime issue. |
Panda's proves the point: a naive datetime may not be as useful as a full-featured Tz-aware one but it is very useful, and users can patch their own TZ handling on top of it. Half-baked TZ support is next to useless. I'm using numpy1.7 datetime64, but frankly, I don't know that I'm buying anything over simply using a regular array that I interpret as seconds-since-the-epoc. Maybe we should borrow Panda's code? As for Naive vs. UTC -- they are almost exactly the same -- the only difference may be how you handle an ISO string as input: add/subtract the offset, or don't allow an offset. As long as you don't apply the locale offset without the user specifically asking for it, I'm good either way, though I think calling it "UTC" buys very little over naive, but does add a tiny bit of extra room for error. So: I propose either Naive or UTC--implementer's choice. -Chris |
Wes I am curious about the motivation for allowing pd.to_datetime( ) to apparently select a timezone from the local system when supplied only a long. That is:
versus
Took me by surprise, but I'm sure you've thought it through. |
This is still under discussion/development for 1.9 |
On Sat, Feb 22, 2014 at 2:46 PM, Charles Harris notifications@git.luolix.topwrote:
-Chris Christopher Barker, PhD Python Language Consulting
|
The timeframe is "whenever someone with the time/skills/interest sits down On Mon, Feb 24, 2014 at 7:08 PM, Christopher H.Barker, PhD <
Nathaniel J. Smith |
Please can this be introduced! Numpy amuses itself by displaying timezone offsets for values which purposefully don't have time-zones - but it makes it look like they do. I happen to travel between time zones quite often (with the machine updating local accordingly) and it would be nice if my program would output the same thing twice rather than trying to be "helpful" in this way. Also, strongly disagree with
A naive datetime is one for which no timezone information is known or desired. It could be for instance you are running a theoretical model with no relation to a real location, so a timezone is meaningless. Its precisely this kind of vagueness that makes dealing with times such a pain, because you end up with data where its never clear if the value you have is in UTC, naive, includes DST, etc - and part of that is because tools (like numpy) don't really help you out and everyone ends up throwing unix timestamps around till no one has a clue what's going on... |
On Thu, Mar 12, 2015 at 11:42 AM, mangecoeur notifications@github.com
I happen to travel between time zones quite often (with the machine
and that, in fact, the the only difference implementation wise- naive, you
-CHB Christopher Barker, PhD Python Language Consulting
|
Just FYI, I'm working on implementing this in #6453. |
A new version of datetime64 dtype was added to numpy recently, and as of 1.7, is considered experimental.
As of 1.7, datetime64 attempts to handle timezones by:
(note that no timezone handling is done when converting to/from the stdlib datetime object)
However, this behavior makes it very difficult to use datetime64 in a timezone agnostic way, or if you need to work with a timezone that is not the system Locale one.
Complete and proper timezone management could be a very useful, but the current system is only useful in a few small cases, and makes common use cases very difficult. Good timezone handling is a large and difficult problem -- it is unclear whether numpy wants to take it on.
There has been much discussion on the numpy mailing list, and a new datetime64 NEP is progress, but in the meantime, I propose we make the following changes to make datetime64 far more useful and less prone to error:
The text was updated successfully, but these errors were encountered: