Skip to content
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

BUG: Printing a timezone-aware datetime series raises #54623

Closed
3 tasks done
AdrianDAlessandro opened this issue Aug 18, 2023 · 1 comment · Fixed by #54625
Closed
3 tasks done

BUG: Printing a timezone-aware datetime series raises #54623

AdrianDAlessandro opened this issue Aug 18, 2023 · 1 comment · Fixed by #54625
Assignees
Labels
Bug Datetime Datetime data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution Output-Formatting __repr__ of pandas objects, to_string Timezones Timezone data dtype
Milestone

Comments

@AdrianDAlessandro
Copy link
Contributor

AdrianDAlessandro commented Aug 18, 2023

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
>>> ser1 = pd.Series(np.array(["2999-01-01"], dtype="datetime64[us]"))
>>> print(ser1) # This is fine
0   2999-01-01
dtype: datetime64[us]
>>> ser2 = pd.Series(np.array(["2999-01-01"], dtype="datetime64[us]")).dt.tz_localize("US/Pacific")
>>> print(ser2) # This breaks
[...]
pandas._libs.tslibs.conversion.convert_datetime_to_tsobject
  File "np_datetime.pyx", line 231, in pandas._libs.tslibs.np_datetime.check_dts_bounds
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2999-01-01 00:00:00, at position 0

Issue Description

Printing a timezone aware datetime Series for non-ns resolution raises OutOfBoundsDatetime error

Expected Behavior

We should be able to print the Series

Installed Versions

INSTALLED VERSIONS

commit : 77bc67a
python : 3.11.1.final.0
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 0+untagged.33100.g77bc67a.dirty
numpy : 1.24.4
pytz : 2023.3
dateutil : 2.8.2
setuptools : 65.5.0
pip : 22.3.1
Cython : 0.29.33
pytest : 7.4.0
hypothesis : 6.82.5
sphinx : 6.2.1
blosc : 1.11.1
feather : None
xlsxwriter : 3.1.2
lxml.etree : 4.9.3
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.7
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader : None
bs4 : 4.12.2
bottleneck : 1.3.7
brotli :
dataframe-api-compat: None
fastparquet : 2023.7.0
fsspec : 2023.6.0
gcsfs : 2023.6.0
matplotlib : 3.7.2
numba : 0.57.1
numexpr : 2.8.5
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 12.0.1
pyreadstat : 1.2.2
pyxlsb : 1.0.10
s3fs : 2023.6.0
scipy : 1.11.2
snappy : None
sqlalchemy : 2.0.20
tables : None
tabulate : 0.9.0
xarray : 2023.7.0
xlrd : 2.0.1
zstandard : 0.21.0
tzdata : 2023.3
qtpy : None
pyqt5 : None

@AdrianDAlessandro AdrianDAlessandro added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 18, 2023
@AdrianDAlessandro
Copy link
Contributor Author

take

@lithomas1 lithomas1 added Datetime Datetime data dtype Output-Formatting __repr__ of pandas objects, to_string Non-Nano datetime64/timedelta64 with non-nanosecond resolution Timezones Timezone data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 19, 2023
@jorisvandenbossche jorisvandenbossche added this to the 2.1 milestone Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Non-Nano datetime64/timedelta64 with non-nanosecond resolution Output-Formatting __repr__ of pandas objects, to_string Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants