1
Попытка среза Panda Dataframe с использованием минут и получение сообщения об ошибке «pandas.tslib.OutOfBoundsDatetime».Pandas. Minute Bar Slicing. Ошибка «pandas.tslib.OutOfBoundsDatetime»
Я понимаю, что я могу порезать данные панды с форматом х [ «HH: MM»: «HH: MM»], но не понимаю, что это неправильно:
min_index
Out[237]:
0 04:00
1 04:01
2 04:04
3 04:05
4 04:07
dtype: object
df=pd.DataFrame(np.arange(5))
x=df.set_index(pd.to_datetime(min_index))
x
Out[241]:
0
TimeBarStart
2017-02-07 04:00:00 0
2017-02-07 04:01:00 1
2017-02-07 04:04:00 2
2017-02-07 04:05:00 3
2017-02-07 04:07:00 4
x['04:01' : '04:05']
Traceback (most recent call last):
File "C:\Users\Chris\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-242-e650c256178d>", line 1, in <module>
x['04:01' : '04:05']
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1985, in __getitem__
indexer = convert_to_index_sliceable(self, key)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\core\indexing.py", line 1758, in convert_to_index_sliceable
return idx._convert_slice_indexer(key, kind='getitem')
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 1079, in _convert_slice_indexer
indexer = self.slice_indexer(start, stop, step, kind=kind)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\tseries\index.py", line 1511, in slice_indexer
return Index.slice_indexer(self, start, end, step, kind=kind)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 2785, in slice_indexer
kind=kind)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 2964, in slice_locs
start_slice = self.get_slice_bound(start, 'left', kind)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 2903, in get_slice_bound
label = self._maybe_cast_slice_bound(label, side, kind)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\tseries\index.py", line 1472, in _maybe_cast_slice_bound
bounds = self._parsed_string_to_bounds(reso, parsed)
File "C:\Users\Chris\Anaconda3\lib\site-packages\pandas\tseries\index.py", line 1297, in _parsed_string_to_bounds
return (Timestamp(st, tz=self.tz),
File "pandas\tslib.pyx", line 295, in pandas.tslib.Timestamp.__new__ (pandas\tslib.c:9203)
File "pandas\tslib.pyx", line 1334, in pandas.tslib.convert_to_tsobject (pandas\tslib.c:25690)
File "pandas\tslib.pyx", line 1562, in pandas.tslib._check_dts_bounds (pandas\tslib.c:29245)
pandas.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1-01-01 04:01:00