Skip to content

BUG?: Series.any / Series.all behavior for pyarrow vs. non-pyarrow empty/all-NA #51624

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
3 tasks done
lukemanley opened this issue Feb 25, 2023 · 2 comments · Fixed by #51631
Closed
3 tasks done

BUG?: Series.any / Series.all behavior for pyarrow vs. non-pyarrow empty/all-NA #51624

lukemanley opened this issue Feb 25, 2023 · 2 comments · Fixed by #51631
Labels
Arrow pyarrow functionality Bug

Comments

@lukemanley
Copy link
Member

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

for dtype in ["bool", "boolean", "boolean[pyarrow]"]:
    ser = pd.Series([], dtype=dtype)
    print(dtype, ser.any(), ser.all())

Issue Description

bool False True
boolean False True
boolean[pyarrow] <NA> <NA>

At the moment Series.any and Series.all have inconsistent behavior for pyarrow vs. non-pyarrow dtypes for empty or all null data. The pyarrow behavior is coming from pyarrow.compute.any and pyarrow.compute.all which return null in these cases. I suspect different behavior here within pandas is likely to be problematic and confusing. Is it OK to diverge from pyarrow here in order to be more consistent within pandas?

Expected Behavior

Probably to match the behavior of non-pyarrow types

Installed Versions

.

@lukemanley lukemanley added Bug Arrow pyarrow functionality labels Feb 25, 2023
@rhshadrach
Copy link
Member

I think the difference is in min_count; pyarrow defaults to 1 whereas pandas (where it exists) defaults to 0. I think pandas should use the pandas default when calling pyarrow.

@lukemanley
Copy link
Member Author

I think the difference is in min_count; pyarrow defaults to 1 whereas pandas (where it exists) defaults to 0. I think pandas should use the pandas default when calling pyarrow.

ah good point. That makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants