times = [datetime(2011, 01, 03, 0, 10 + i, 0) for i in range(5)]
series = pd.TimeSeries(range(5), index=times)
series.ix[datetime(2011, 01, 03, 0, 10, 0):datetime(2011, 01, 03, 0, 13, 0)]
2011-01-03 00:10:00 0
2011-01-03 00:11:00 1
2011-01-03 00:12:00 2
2011-01-03 00:13:00 3
しかし
x = range(5)
x[0:3]
[0, 1, 2]
また、
times = [datetime.datetime(2000, 1, 1) + datetime.timedelta(minutes=i) for i in range(1000000 - 1)]
df = pd.TimeSeries(range(1000000 - 1), times)
len(df.ix[datetime.datetime(1900,1,1):datetime.datetime(2100,1,1)])
999999
だが
times = [datetime.datetime(2000, 1, 1) + datetime.timedelta(minutes=i) for i in range(1000000)]
df = pd.TimeSeries(range(1000000), times)
len(df.ix[datetime.datetime(1900,1,1):datetime.datetime(2100,1,1)])
トレースバック(最後の最後の呼び出し):
File "C:\Program Files (x86)\Wing IDE 4.1\src\debug\tserver\_sandbox.py", line 1, in <module> # Used internally for debug sandbox under external interpreter File "C:\dev\Python26\Lib\site-packages\pandas\core\indexing.py", line 35, in __getitem__ return self._getitem_axis(key, axis=0) File "C:\dev\Python26\Lib\site-packages\pandas\core\indexing.py", line 234, in _getitem_axis return self._get_slice_axis(key, axis=axis) File "C:\dev\Python26\Lib\site-packages\pandas\core\indexing.py", line 460, in _get_slice_axis i, j = labels.slice_locs(start, stop) File "C:\dev\Python26\Lib\site-packages\pandas\tseries\index.py", line 949, in slice_locs return Index.slice_locs(self, start, end) File "C:\dev\Python26\Lib\site-packages\pandas\core\index.py", line 1057, in slice_locs end_slice = self.get_loc(end) + 1 File "C:\dev\Python26\Lib\site-packages\pandas\tseries\index.py", line 919, in get_loc return self._engine.get_loc(key) File "C:\dev\Python26\Lib\site-packages\pandas\lib.pyd", line 378, in pandas.lib.DatetimeEngine.get_loc (pandas\src\tseries.c:108808) File "C:\dev\Python26\Lib\site-packages\pandas\lib.pyd", line 390, in pandas.lib.DatetimeEngine.get_loc (pandas\src\tseries.c:108422) File "C:\dev\Python26\Lib\site-packages\pandas\lib.pyd", line 32, in util.get_value_at (pandas\src\tseries.c:112091) IndexError: index out of bounds