You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fixes in #18424 allow for and IntervalIndex to be constructed with tz aware timestamps, but there are a few attributes/methods that still do not work properly with tz aware:
Disallow an IntervalIndex to contain elements with differing tz
IntervalIndex.mid returns tz naive
Anything using _get_next_label or _get_previous_label will raise
get_indexer when passed an IntervalIndex
get_loc for overlapping/non-monotonic IntervalIndex
contains always returns False for overlapping/non-monotonic due to Try/Except
etc.
Code Sample, a copy-pastable example if possible
Setup:
In [2]: start=pd.Timestamp('2017-01-01', tz='US/Eastern')
...: index=pd.interval_range(start, periods=3)
...: index
...:
Out[2]:
IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03], (2017-01-03, 2017-01-04]]
closed='right',
dtype='interval[datetime64[ns, US/Eastern]]')
In [4]: index.get_indexer(index[:-1])
---------------------------------------------------------------------------TypeError: cannotdeterminenextlabelfor type <class'pandas.core.indexes.datetimes.DatetimeIndex'>
Differing tz:
In [5]: left=pd.date_range('2017-01-01', periods=3, tz='US/Eastern')
...: right=pd.date_range('2017-01-02', periods=3, tz='US/Pacific')
...: index=pd.IntervalIndex.from_arrays(left, right)
...: index
...:
Out[5]:
IntervalIndex([(2017-01-01, 2017-01-02], (2017-01-02, 2017-01-03], (2017-01-03, 2017-01-04]]
closed='right',
dtype='interval[datetime64[ns, US/Eastern]]')
In [6]: index.left.dtypeOut[6]: datetime64[ns, US/Eastern]
In [7]: index.right.dtypeOut[7]: datetime64[ns, US/Pacific]
The text was updated successfully, but these errors were encountered:
Side question: Should a plain Interval be able to hold timestamps with different tz? Seems a bit strange, but since different tz are comparable, I don't want to outright declare this a bug.
In [2]: left=pd.Timestamp('2017-01-01', tz='US/Eastern')
...: right=pd.Timestamp('2017-01-02', tz='US/Pacific')
...: iv=pd.Interval(left, right)
...:
In [3]: ivOut[3]: Interval('2017-01-01', '2017-01-02', closed='right')
In [4]: iv.leftOut[4]: Timestamp('2017-01-01 00:00:00-0500', tz='US/Eastern')
In [5]: iv.rightOut[5]: Timestamp('2017-01-02 00:00:00-0800', tz='US/Pacific')
Note that an Interval cannot be constructed from an a combination of aware and naive timestamps, as the two aren't comparable:
Problem description
The fixes in #18424 allow for and
IntervalIndex
to be constructed with tz aware timestamps, but there are a few attributes/methods that still do not work properly with tz aware:IntervalIndex
to contain elements with differing tzIntervalIndex.mid
returns tz naive_get_next_label
or_get_previous_label
will raiseget_indexer
when passed anIntervalIndex
get_loc
for overlapping/non-monotonicIntervalIndex
contains
always returnsFalse
for overlapping/non-monotonic due toTry
/Except
Code Sample, a copy-pastable example if possible
Setup:
IntervalIndex.mid
returns tz naive:get_indexer
raises when passed anIntervalIndex
:Differing tz:
The text was updated successfully, but these errors were encountered: