Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
set_index(DatetimeIndex) unexpectedly shifts tz-aware datetime #12358
Comments
jreback
added Usage Question Timezones
labels
Feb 16, 2016
|
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.
|
jreback
closed this
Feb 16, 2016
wavexx
commented
Feb 17, 2016
|
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. |
wavexx
commented
Feb 17, 2016
|
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
|
wavexx
commented
Feb 17, 2016
|
On Wed, Feb 17 2016, Jeff Reback notifications@github.com 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 |
jreback
added a commit
to jreback/pandas
that referenced
this issue
Feb 17, 2016
|
|
jreback |
46d5c9d
|
jreback
added Bug and removed Usage Question
labels
Feb 17, 2016
jreback
added this to the
0.18.0
milestone
Feb 17, 2016
jreback
referenced
this issue
Feb 17, 2016
Closed
BUG: Bug in DataFrame.set_index() with tz-aware Series #12365
jreback
reopened this
Feb 17, 2016
|
looks like a bug after all! fixed by #12365 |
wavexx
commented
Feb 17, 2016
|
On Wed, Feb 17 2016, Jeff Reback notifications@github.com 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. |
jreback
closed this
in 69baf4c
Feb 17, 2016
rinoc
added a commit
to rinoc/pandas
that referenced
this issue
Feb 17, 2016
|
|
rinoc |
555a76f
|
wavexx commentedFeb 16, 2016
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: