Skip to content

BUG: OverflowError when fillna on DataFrame with a pd.Timestamp #61208

Closed
@thecurve8

Description

@thecurve8

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 pandas as pd

df = pd.DataFrame({
'datetime' : pd.date_range('1/1/2011', periods=3, freq='h'),
'value' : [1,2,3]
})

df.iloc[0,0] = None
df.fillna(pd.Timestamp('0001-01-01'), inplace=True)

Issue Description

Issue is similar to this closed issue without a reproducible example.

A DataFrame that has a column with datetime64[ns] with NaT gets an error if trying to fill null values with a pd.Timestamp that lies outside the range of the given precision.

Expected Behavior

The null values in the DataFrame should be replaced with the provided TimeStamp or an error should be provided to the user that the Timestamps have incompatible precisions and ranges.

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.10.8
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.17763
machine : AMD64
processor : Intel64 Family 6 Model 143 Stepping 8, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : German_Switzerland.1252

pandas : 2.2.3
numpy : 2.2.4
pytz : 2025.2
dateutil : 2.9.0.post()
pip : 25.0.1
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

Labels

BugError ReportingIncorrect or improved errors from pandasTimestamppd.Timestamp and associated methods

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions