PeriodIndex slicing by datetime fails when either end out-of-bounds · Issue #1977 · pandas-dev/pandas (original) (raw)
pi = pandas.PeriodIndex(start='2012-01-01', periods=10, freq='W-MON')
ts = pandas.TimeSeries(range(len(pi)), index=pi)
dt1 = datetime.datetime(2011, 10, 2)
dt2 = datetime.datetime(2012, 1, 2)
dt3 = datetime.datetime(2012, 2, 10)
dt4 = datetime.datetime(2012, 4, 20)
ts[dt2: dt3]
ts[dt1: dt3]
ts[dt2: dt4]
The first slice works, the second and third do not. It looks like the code that handles 'out-of-bounds' slices is failing in this case.