Skip to content

BUG: scalar out of bounds input does not raise for to_datetime #60677

Open
@kmuehlbauer

Description

@kmuehlbauer

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

import numpy as np
import pandas as pd
uint64_max = np.iinfo("uint64").max

try:
    dtime = pd.to_datetime(uint64_max, unit="ns")
    print("Wrong:", dtime)
    dtime = pd.to_datetime([uint64_max], unit="ns")
except Exception as err:
    print(err)

Wrong: 1969-12-31 23:59:59.999999999
cannot convert input 18446744073709551615 with the unit 'ns', at position 0

Issue Description

Trying to convert out of bounds input does not raise for scalar input.

Expected Behavior

Should raise.

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.4
python-bits : 64
OS : Linux
OS-release : 5.14.21-150500.55.83-default
Version : #1 SMP PREEMPT_DYNAMIC Wed Oct 2 08:09:07 UTC 2024 (0d53847)
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8

pandas : 2.2.3
numpy : 2.2.1
pytz : 2024.1
dateutil : 2.9.0
pip : 24.0
Cython : None
sphinx : 8.1.0
IPython : 8.25.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : 1.4.0
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.6.1
html5lib : None
hypothesis : 6.114.1
gcsfs : None
jinja2 : 3.1.4
lxml.etree : 5.2.2
matplotlib : 3.10.0
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 17.0.0
pyreadstat : None
pytest : 8.2.2
python-calamine : None
pyxlsb : None
s3fs : 2024.6.1
scipy : 1.14.0
sqlalchemy : None
tables : None
tabulate : 0.9.0
xarray : 2025.1.1.dev3+g251329e3
xlrd : None
xlsxwriter : None
zstandard : 0.22.0
tzdata : 2024.1
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

Labels

BugError ReportingIncorrect or improved errors from pandasdatetime.datestdlib datetime.date support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions