Open arfriedman opened 9 months ago
I just updated to Pandas 2.2.0 and received the same error:
In [4]: ts.loc["1600"]
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
File period.pyx:1169, in pandas._libs.tslibs.period.period_ordinal_to_dt64()
OverflowError: Overflow occurred in npy_datetimestruct_to_datetime
The above exception was the direct cause of the following exception:
OutOfBoundsDatetime Traceback (most recent call last)
Cell In[4], line 1
----> 1 ts.loc["1600"]
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexing.py:1192, in _LocationIndexer.__getitem__(self, key)
1190 maybe_callable = com.apply_if_callable(key, self.obj)
1191 maybe_callable = self._check_deprecated_callable_usage(key, maybe_callable)
-> 1192 return self._getitem_axis(maybe_callable, axis=axis)
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexing.py:1432, in _LocIndexer._getitem_axis(self, key, axis)
1430 # fall thru to straight lookup
1431 self._validate_key(key, axis)
-> 1432 return self._get_label(key, axis=axis)
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexing.py:1382, in _LocIndexer._get_label(self, label, axis)
1380 def _get_label(self, label, axis: AxisInt):
1381 # GH#5567 this will fail if the label is not present in the axis.
-> 1382 return self.obj.xs(label, axis=axis)
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/generic.py:4295, in NDFrame.xs(self, key, axis, level, drop_level)
4293 new_index = index[loc]
4294 else:
-> 4295 loc = index.get_loc(key)
4297 if isinstance(loc, np.ndarray):
4298 if loc.dtype == np.bool_:
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexes/datetimes.py:610, in DatetimeIndex.get_loc(self, key)
608 if self._can_partial_date_slice(reso):
609 try:
--> 610 return self._partial_date_slice(reso, parsed)
611 except KeyError as err:
612 raise KeyError(key) from err
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexes/datetimelike.py:324, in DatetimeIndexOpsMixin._partial_date_slice(self, reso, parsed)
321 if not self._can_partial_date_slice(reso):
322 raise ValueError
--> 324 t1, t2 = self._parsed_string_to_bounds(reso, parsed)
325 vals = self._data._ndarray
326 unbox = self._data._unbox
File ~/miniconda3/envs/Nile-Laki/lib/python3.11/site-packages/pandas/core/indexes/datetimes.py:538, in DatetimeIndex._parsed_string_to_bounds(self, reso, parsed)
536 freq = OFFSET_TO_PERIOD_FREQSTR.get(reso.attr_abbrev, reso.attr_abbrev)
537 per = Period(parsed, freq=freq)
--> 538 start, end = per.start_time, per.end_time
540 # GH 24076
541 # If an incoming date string contained a UTC offset, need to localize
542 # the parsed date to this offset first before aligning with the index's
543 # timezone
544 start = start.tz_localize(parsed.tzinfo)
File period.pyx:1666, in pandas._libs.tslibs.period.PeriodMixin.start_time.__get__()
File period.pyx:1992, in pandas._libs.tslibs.period._Period.to_timestamp()
File period.pyx:1172, in pandas._libs.tslibs.period.period_ordinal_to_dt64()
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1600-01-01 00:00:00
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I receive an error trying to index a timeseries with second resolution outside the standard nanosecond range. It appears that the time series is being converted to nanosecond resolution during the indexing operation.
I believe this is issue would fall under https://github.com/pandas-dev/pandas/issues/46587
Expected Behavior
The expected behavior would function as it does within the standard nanosecond range:
In [3]: ts.loc["1700"] Out[3]: 1700-12-31 699 Freq: A-DEC, dtype: int64
Installed Versions