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
import pandas as pd
import numpy as np
ser_index = pd.DatetimeIndex([
np.datetime64('0000-01-01', 's'),
np.datetime64('2000-01-01', 's'),
])
Issue Description
Traceback (most recent call last):
Cell In[1], line 1
ser_index = pd.DatetimeIndex([
NameError: name 'pd' is not defined
import pandas as pd
import numpy as np
ser_index = pd.DatetimeIndex([
np.datetime64('0000-01-01', 's'),
np.datetime64('2000-01-01', 's'),
])
Traceback (most recent call last):
File conversion.pyx:294 in pandas._libs.tslibs.conversion.get_datetime64_nanos
OverflowError: Overflow occurred in npy_datetimestruct_to_datetime
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
Cell In[4], line 1
ser_index = pd.DatetimeIndex([
File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/indexes/datetimes.py:370 in new
dtarr = DatetimeArray._from_sequence_not_strict(
File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:369 in _from_sequence_not_strict
subarr, tz = _sequence_to_dt64(
File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:2248 in _sequence_to_dt64
converted, inferred_tz = objects_to_datetime64(
File ~/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py:2398 in objects_to_datetime64
result, tz_parsed = tslib.array_to_datetime(
File tslib.pyx:414 in pandas._libs.tslib.array_to_datetime
File tslib.pyx:596 in pandas._libs.tslib.array_to_datetime
File tslib.pyx:520 in pandas._libs.tslib.array_to_datetime
File conversion.pyx:297 in pandas._libs.tslibs.conversion.get_datetime64_nanos
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 0000-01-01T00:00:00, at position 0
Expected Behavior
Used to work as of 2.0.4.
Installed Versions
/Users/deborahkhider/opt/anaconda3/envs/paleopandas/lib/python3.10/site-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
INSTALLED VERSIONS
commit : fd3f571
python : 3.10.8.final.0
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.0
numpy : 1.24.3
pytz : 2023.3
dateutil : 2.8.2
setuptools : 67.7.2
pip : 23.1.2
Cython : 0.29.33
pytest : None
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.2
bottleneck : 1.3.6
dataframe-api-compat : None
fastparquet : None
fsspec : 2023.6.0
gcsfs : None
matplotlib : 3.6.3
numba : 0.57.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.12.0
sqlalchemy : 2.0.23
tables : None
tabulate : 0.9.0
xarray : 2023.1.0
xlrd : 2.0.1
zstandard : None
tzdata : 2023.3
qtpy : 2.3.1
pyqt5 : None