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.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import numpy as np
import datetime
pd.DataFrame([np.nan], dtype='datetime64[ns]').replace(np.nan, datetime.datetime(3000,1,1))
Issue Description
code above gives this error, likely because the datetime is too big for datetime64[ns]:
pd.DataFrame([np.nan], dtype='datetime64[ns]').replace(np.nan, datetime.datetime(3000,1,1))
File "C:\Users\mdarnall\mdarnall-local-dev\tma-venv-prod.venv\lib\site-packages\pandas\core\generic.py", line 8141, in replace new_data = self._mgr.replace( File "C:\Users\mdarnall\mdarnall-local-dev\tma-venv-prod.venv\lib\site-packages\pandas\core\internals\base.py", line 249, in replace return self.apply_with_block( File "C:\Users\mdarnall\mdarnall-local-dev\tma-venv-prod.venv\lib\site-packages\pandas\core\internals\managers.py", line 363, in apply applied = getattr(b, f)(**kwargs) File "C:\Users\mdarnall\mdarnall-local-dev\tma-venv-prod.venv\lib\site-packages\pandas\core\internals\blocks.py", line 924, in replace blk = self.coerce_to_target_dtype(value) File "C:\Users\mdarnall\mdarnall-local-dev\tma-venv-prod.venv\lib\site-packages\pandas\core\internals\blocks.py", line 490, in coerce_to_target_dtype raise AssertionError( AssertionError: Something has gone wrong, please report a bug at https://github.com/pandas-dev/pandas/issues
Expected Behavior
different error message or change column type
Installed Versions
Comment From: iabhi4
take