Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
In [1]: date_range('300-01-01', '2000-01-01', unit='s')
---------------------------------------------------------------------------
OutOfBoundsDatetime Traceback (most recent call last)
Cell In[1], line 1
----> 1 date_range('300-01-01', '2000-01-01', unit='s')
File ~/pandas-dev/pandas/core/indexes/datetimes.py:970, in date_range(start, end, periods, freq, tz, normalize, name, inclusive, unit, **kwargs)
967 if freq is None and com.any_none(periods, start, end):
968 freq = "D"
--> 970 dtarr = DatetimeArray._generate_range(
971 start=start,
972 end=end,
973 periods=periods,
974 freq=freq,
975 tz=tz,
976 normalize=normalize,
977 inclusive=inclusive,
978 unit=unit,
979 **kwargs,
980 )
981 return DatetimeIndex._simple_new(dtarr, name=name)
File ~/pandas-dev/pandas/core/arrays/datetimes.py:399, in DatetimeArray._generate_range(cls, start, end, periods, freq, tz, normalize, ambiguous, nonexistent, inclusive, unit)
396 freq = to_offset(freq)
398 if start is not None:
--> 399 start = Timestamp(start)
401 if end is not None:
402 end = Timestamp(end)
File ~/pandas-dev/pandas/_libs/tslibs/timestamps.pyx:1637, in pandas._libs.tslibs.timestamps.Timestamp.__new__()
1635 raise ValueError("nanosecond must be in 0..999")
1636
-> 1637 ts = convert_to_tsobject(ts_input, tzobj, unit, 0, 0, nanosecond)
1638
1639 if ts.value == NPY_NAT:
File ~/pandas-dev/pandas/_libs/tslibs/conversion.pyx:281, in pandas._libs.tslibs.conversion.convert_to_tsobject()
279
280 if isinstance(ts, str):
--> 281 return convert_str_to_tsobject(ts, tz, unit, dayfirst, yearfirst)
282
283 if ts is None or ts is NaT:
File ~/pandas-dev/pandas/_libs/tslibs/conversion.pyx:558, in pandas._libs.tslibs.conversion.convert_str_to_tsobject()
556 )
557
--> 558 return convert_datetime_to_tsobject(dt, tz)
559
560
File ~/pandas-dev/pandas/_libs/tslibs/conversion.pyx:415, in pandas._libs.tslibs.conversion.convert_datetime_to_tsobject()
413 obj.value -= int(offset.total_seconds() * pps)
414
--> 415 check_dts_bounds(&obj.dts, reso)
416 check_overflows(obj, reso)
417 return obj
File ~/pandas-dev/pandas/_libs/tslibs/np_datetime.pyx:218, in pandas._libs.tslibs.np_datetime.check_dts_bounds()
216 f"{dts.hour:02d}:{dts.min:02d}:{dts.sec:02d}")
217 # TODO: "nanosecond" in the message assumes NPY_FR_ns
--> 218 raise OutOfBoundsDatetime(f"Out of bounds nanosecond timestamp: {fmt}")
219
220
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 300-01-01 00:00:00
Issue Description
error mentions nanosecond timestamp
, and isn't particularly clear
Expected Behavior
Either a clearer message, or to parse it despite the missing leading zero. Not sure, will take a closer look
Installed Versions
INSTALLED VERSIONS
commit : 9594c04
python : 3.8.16.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 2.0.0.dev0+1336.g9594c04eb7
numpy : 1.23.5
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 66.1.1
pip : 22.3.1
Cython : 0.29.32
pytest : 7.2.1
hypothesis : 6.64.0
sphinx : 5.3.0
blosc : 1.11.1
feather : None
xlsxwriter : 3.0.7
lxml.etree : 4.9.2
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : 2.9.5
jinja2 : 3.1.2
IPython : 8.8.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.6
brotli :
fastparquet : 2023.1.0
fsspec : 2022.11.0
gcsfs : 2022.11.0
matplotlib : 3.6.3
numba : 0.56.4
numexpr : 2.8.4
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : 1.2.0
pyxlsb : 1.0.10
s3fs : 2022.11.0
scipy : 1.10.0
snappy :
sqlalchemy : 1.4.45
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.1.0
xlrd : 2.0.1
zstandard : 0.19.0
tzdata : 2022.7
qtpy : None
pyqt5 : None
None