-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
set_index(DatetimeIndex) unexpectedly shifts tz-aware datetime #12358
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
a couple of things:
so construct the index like this. IOW. you have to say, hey this a local UTC time, THEN convert it.
This is a nonsensical operation, what do you think this should do? you probably mean You are effectively setting the index with a 'key' from they array; this technically works as you only have 1 element (otherwise it would raise). but as I said doesn't make any sense.
|
It seems clear enough to me that if I know the tz of the series, there's no point to "localize" it later. As for setting the index, yes, it's dodgy. It's a reduced test-case from some convoluted code. |
passing it rather than explicity localizing leads to a lot of ambiguity, what should I doing here?
as to your second point, it is converted to a numpy array, thus the tz is lost. the first arg only accepts a list or np.array NOT a Series, excactly for this reason. |
tz_localize() converts the timezone, I explicitly don't want it to do any conversion as my dates do not contain any. In fact, if I could bug you one more time about this, what's the more efficient way to start from a unix timestamp (obviously in UTC) and get to a localized series? |
NO Here's some examples. You CAN use the
|
On Wed, Feb 17 2016, Jeff Reback [email protected] wrote:
Ok, this made things a little bit clearer regarding the tz. I'm still not super-happy about the set_index behavior. I've given it Where exactly this conversion happens? import pandas as pd => 11 11 10 Ignore the fact that I could assign to index for a moment. I'm supplying a type to set_index that should be equivalent to the |
looks like a bug after all! fixed by #12365 |
On Wed, Feb 17 2016, Jeff Reback [email protected] wrote:
Sorry for being pedantic! |
no, persistence is good! you got me to actually step thru and see what was happening. always better to test. |
This is another issue I've found in code that used to work:
writes:
It's unclear to me why the time is shifted. If we take a pd.DatetimeIndex which is not directly contained in the df, it works as it should:
The text was updated successfully, but these errors were encountered: