У меня есть временной ряд, который выглядит следующим образом:
y.index = pd.to_datetime(y.index)
y.index = y.index.tz_localize(None)
Когда я пытаюсь нарезать строки, используя следующее выражение, я получаю следующая ошибка:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-677-f1b3153cb92b> in <module>
----> 1 y['2020-02-24 10-11-12':]
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\series.py in __getitem__(self, key)
863 key = check_bool_indexer(self.index, key)
864
--> 865 return self._get_with(key)
866
867 def _get_with(self, key):
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\series.py in _get_with(self, key)
868 # other: fancy integer or otherwise
869 if isinstance(key, slice):
--> 870 return self._slice(key)
871 elif isinstance(key, ABCDataFrame):
872 raise TypeError(
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\series.py in _slice(self, slobj, axis, kind)
818
819 def _slice(self, slobj: slice, axis: int = 0, kind=None):
--> 820 slobj = self.index._convert_slice_indexer(slobj, kind=kind or "getitem")
821 return self._get_values(slobj)
822
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\base.py in _convert_slice_indexer(self, key, kind)
2943 indexer = key
2944 else:
-> 2945 indexer = self.slice_indexer(start, stop, step, kind=kind)
2946
2947 return indexer
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\datetimes.py in slice_indexer(self, start, end, step, kind)
806
807 try:
--> 808 return Index.slice_indexer(self, start, end, step, kind=kind)
809 except KeyError:
810 # For historical reasons DatetimeIndex by default supports
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\base.py in slice_indexer(self, start, end, step, kind)
4675 slice(1, 3)
4676 """
-> 4677 start_slice, end_slice = self.slice_locs(start, end, step=step, kind=kind)
4678
4679 # return a slice
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\base.py in slice_locs(self, start, end, step, kind)
4888 start_slice = None
4889 if start is not None:
-> 4890 start_slice = self.get_slice_bound(start, "left", kind)
4891 if start_slice is None:
4892 start_slice = 0
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\base.py in get_slice_bound(self, label, side, kind)
4800 # For datetime indices label may be a string that has to be converted
4801 # to datetime boundary according to its resolution.
-> 4802 label = self._maybe_cast_slice_bound(label, side, kind)
4803
4804 # we need to look up the label
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\datetimes.py in _maybe_cast_slice_bound(self, label, side, kind)
761 freq = getattr(self, "freqstr", getattr(self, "inferred_freq", None))
762 _, parsed, reso = parsing.parse_time_string(label, freq)
--> 763 lower, upper = self._parsed_string_to_bounds(reso, parsed)
764 # lower, upper form the half-open interval:
765 # [parsed, parsed + 1 freq)
~\Anaconda3\envs\tf2\lib\site-packages\pandas\core\indexes\datetimes.py in _parsed_string_to_bounds(self, reso, parsed)
569 if self.tz is None:
570 raise ValueError(
--> 571 "The index must be timezone aware when indexing "
572 "with a date string with a UTC offset"
573 )
ValueError: The index must be timezone aware when indexing with a date string with a UTC offset
Я предоставляю ограниченную часть этой серии для воспроизводимости (формат json):
'{"1582539072500":1,"1582539073000":1,"1582539073500":1,"1582539074000":1,"1582539074500":1,"1582539075000":1,"1582539075500":1,"1582539076000":1,"1582539076500":1,"1582539077000":1,"1582539077500":1,"1582539078000":1,"1582539078500":1,"1582539080500":1,"1582539081000":1,"1582539081500":1,"1582539082000":1,"1582539082500":1,"1582539083000":1,"1582539083500":1,"1582539084000":1,"1582539084500":1,"1582539085000":1,"1582539085500":1,"1582539086000":1,"1582539086500":1,"1582539088500":1,"1582539089000":1,"1582539089500":1,"1582539090000":1,"1582539090500":1,"1582539091000":1,"1582539091500":1,"1582539092500":1,"1582539093000":1,"1582539093500":1,"1582539094000":1,"1582539094500":1,"1582539095000":1,"1582539095500":1,"1582539096000":1,"1582539097500":1,"1582539099500":1,"1582539101000":1,"1582539101500":1,"1582539104000":1,"1582539104500":1,"1582539105500":1,"1582539106000":1,"1582539109000":1}'
Что создает ошибку, почему мои действия не решить и что мне делать?