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/REF: ArrowExtensionArray non-nanosecond units #53171

Merged
merged 13 commits into from
May 16, 2023

Conversation

lukemanley
Copy link
Member

Fixes a few bugs related to non-nanosecond units for pyarrow duration and timestamp types.

The underlying issue is upstream (apache/arrow#33321) where pyarrow does not handle pandas Timedelta and Timestamp non-nano units correctly.

Example (1 seconds -> 0 seconds):

In [1]: import pandas as pd

In [2]: import pyarrow as pa

In [3]: td = pd.Timedelta(1, unit="s").as_unit("s")

In [4]: pa.scalar(td, type=pa.duration("s"))
Out[4]: <pyarrow.DurationScalar: datetime.timedelta(0)>

In [5]: pa.array([td], type=pa.duration("s"))
Out[5]: 
<pyarrow.lib.DurationArray object at 0x10751d120>
[
  0
]

@lukemanley lukemanley added Bug Arrow pyarrow functionality Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels May 10, 2023
@lukemanley lukemanley added the Upstream issue Issue related to pandas dependency label May 10, 2023
else:
# GH 53171: pyarrow does not yet handle pandas non-nano correctly
# see https://github.com/apache/arrow/issues/33321
from pandas._libs.tslibs import (
Copy link
Member

Choose a reason for hiding this comment

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

Is there a circular import if this is put at the top?

Copy link
Member Author

Choose a reason for hiding this comment

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

updated, this is now at the top

@jbrockmendel
Copy link
Member

Is there some amount of this we can hope to rip out once pyarrow is updated?

@lukemanley
Copy link
Member Author

Is there some amount of this we can hope to rip out once pyarrow is updated?

I think it can all be removed eventually. It may take some time as it needs to be fixed upstream first and then the pyarrow min version needs to catch up.

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Looks okay. Just a merge conflict

@mroeschke mroeschke added this to the 2.1 milestone May 16, 2023
@mroeschke mroeschke merged commit c96dbb7 into pandas-dev:main May 16, 2023
@mroeschke
Copy link
Member

Thanks @lukemanley

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
* BUG/REF: ArrowExtensionArray non-nanosecond units

* mypy

* gh refs

* fixes

* xfail min versions

* docstrings

* fix test

* fix test

* update imports

* move imports
topper-123 pushed a commit to topper-123/pandas that referenced this pull request May 22, 2023
* BUG/REF: ArrowExtensionArray non-nanosecond units

* mypy

* gh refs

* fixes

* xfail min versions

* docstrings

* fix test

* fix test

* update imports

* move imports
@lukemanley lukemanley deleted the arrow-non-nano branch May 30, 2023 22:16
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
* BUG/REF: ArrowExtensionArray non-nanosecond units

* mypy

* gh refs

* fixes

* xfail min versions

* docstrings

* fix test

* fix test

* update imports

* move imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug Non-Nano datetime64/timedelta64 with non-nanosecond resolution Upstream issue Issue related to pandas dependency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants