-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Labels
BugDatetimeDatetime data dtypeDatetime data dtypeMultiIndexTimezonesTimezone data dtypeTimezone data dtype
Milestone
Description
dat = pd.DataFrame({'label':['a', 'a', 'a', 'b', 'b', 'b'], 'datetime':['2011-07-19 07:00:00', '2011-07-19 08:00:00', '2011-07-19 09:00:00', '2011-07-19 07:00:00', '2011-07-19 08:00:00', '2011-07-19 09:00:00'], 'value':range(6)}) dat.index = pd.to_datetime(dat.pop('datetime'), utc=True) dat.index = dat.index.tz_localize('UTC').tz_convert('US/Pacific') dat label value datetime 2011-07-19 00:00:00-07:00 a 0 2011-07-19 01:00:00-07:00 a 1 2011-07-19 02:00:00-07:00 a 2 2011-07-19 00:00:00-07:00 b 3 2011-07-19 01:00:00-07:00 b 4 2011-07-19 02:00:00-07:00 b 5 If we add another index (we lose the tz):
In [14]: dat.set_index('label', append=True).swaplevel(0, 1) Out[14]: value label datetime a 2011-07-19 07:00:00 0 2011-07-19 08:00:00 1 2011-07-19 09:00:00 2 b 2011-07-19 07:00:00 3 2011-07-19 08:00:00 4 2011-07-19 09:00:00 5 Metadata
Metadata
Assignees
Labels
BugDatetimeDatetime data dtypeDatetime data dtypeMultiIndexTimezonesTimezone data dtypeTimezone data dtype