Skip to content

read_excel parsing dates later than 2262-04-11 pandas.to_datetime cannot convert input with unit 'D' #48243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
petrdanecek opened this issue Aug 25, 2022 · 2 comments
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timestamp pd.Timestamp and associated methods Usage Question

Comments

@petrdanecek
Copy link

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

works fine:
pandas.to_datetime(132320, unit='D', origin='1899-12-30')
>> Timestamp('2262-04-11 00:00:00')

results in exception:
pandas.to_datetime(132322, unit='D', origin='1899-12-30')
>> *** pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: cannot convert input with unit 'D'

Issue Description

not able to process the xlsb with dates later than 2262-04-11

Expected Behavior

pandas.to_datetime(132322, unit='D', origin='1899-12-30')

should return valid date

Installed Versions

pd.show_versions()
*** NameError: name 'pd' is not defined
(Pdb) pandas.show_versions()

INSTALLED VERSIONS

commit : e8093ba
python : 3.10.2.final.0
python-bits : 64
OS : Linux
OS-release : 4.18.0-394.el8.x86_64
Version : #1 SMP Tue May 31 16:19:11 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.3
numpy : 1.22.4
pytz : 2022.1
dateutil : 2.8.2
setuptools : 62.6.0
pip : 22.2.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.5
html5lib : None
pymysql : None
psycopg2 : 2.9.3
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : 1.0.9
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None

@petrdanecek petrdanecek added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 25, 2022
@phofl
Copy link
Member

phofl commented Aug 25, 2022

Hi, thanks for your report. This is a problem with the underlying representation of date times (ns). See https://numpy.org/doc/stable/reference/arrays.datetime.html#datetime-units

This is the maximum that can be represented.

@phofl phofl added Usage Question Timestamp pd.Timestamp and associated methods and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 25, 2022
@mroeschke
Copy link
Member

This is further noted in https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timestamp-limitations

Additionally, this should hopefully change with non-nano support in the works: #46587. Closing as it overlaps with the above issue

@mroeschke mroeschke added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timestamp pd.Timestamp and associated methods Usage Question
Projects
None yet
Development

No branches or pull requests

3 participants