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: fix convert_dtypes to preserve timezone from tz-aware pyarrow timestamp dtype #60304

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

road-1
Copy link

@road-1 road-1 commented Nov 13, 2024

Removed if statement blocks that were causing timezone to be removed, added a test to confirm that bug is fixed, and added BUG fix to 3.0.0 documentation.
Fixes issue in #60237

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! There are some test failures though (it seems that for older pyarrow versions, this now looses the datetime64 unit?)

# regardless of the pyarrow duration units
# This can be removed if/when pyarrow addresses it:
# https://github.com/apache/arrow/issues/34462
return np.dtype(f"timedelta64[{self.pyarrow_dtype.unit}]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing this, it will go through np.dtype(self.pyarrow_dtype.to_pandas_dtype()), which I think will raise a type error? (because to_pandas_dtype returns a DatetimeTZDtype, and np.dtype(..) does not recognize that) And so this will start to return object dtype instead of datetime64?

@jorisvandenbossche jorisvandenbossche changed the title BUG: fixed .convert_dtypes timezone strip from tz-aware pyarrow timestamp Series BUG: fix convert_dtypes to preserve timezone from tz-aware pyarrow timestamp dtype Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants