I have a time series indexed by datetime.date. Here are the first nodes in the series:
1999-12-31 0 2000-06-30 170382.118454 2000-12-29 -319260.443362
I want to truncate from the beginning of the series until December 28, 2000, but this does not work, because this date is not indicated in the index (I get a KeyError when trying original_series[:datetime.date(2000,12,28)] . I also tried to convert the index for timestamps, but this gives very false results (it produces fake nodes, see below), so I wondered if there is a good approach to this problem.
test = pd.Series(original_series.values, map(pd.Timestamp, original_series.index))
At first glance, this looks good:
1999-12-31 0.000000 2000-06-30 170382.118454 2000-12-29 -319260.443362
But then I try to make my own cut (where did these extra days come from in January 2000?):
In [84]: test[:'2000-12-28'] Out[84]: 1999-12-31 0.000000 2000-06-30 170382.118454 2000-01-03 -71073.979016 2000-01-04 100498.744748 2000-01-05 91104.743684 2000-01-06 82290.255459
source share