Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ ExtensionArray
- Bug in :class:`Series` constructor unnecessarily overflowing for nullable unsigned integer dtypes (:issue:`38798`, :issue:`25880`)
- Bug in setting non-string value into ``StringArray`` raising ``ValueError`` instead of ``TypeError`` (:issue:`49632`)
- Bug in :meth:`DataFrame.reindex` not honoring the default ``copy=True`` keyword in case of columns with ExtensionDtype (and as a result also selecting multiple columns with getitem (``[]``) didn't correctly result in a copy) (:issue:`51197`)
- Bug in :meth:`Series.any` and :meth:`Series.all` returning ``NA`` for empty or all null pyarrow-backed data when ``skipna=True`` (:issue:`51624`)
- Bug in :class:`~arrays.ArrowExtensionArray` logical operations ``&`` and ``|`` raising ``KeyError`` (:issue:`51688`)

Styler
Expand Down
4 changes: 4 additions & 0 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,10 @@ def pyarrow_meth(data, skip_nulls, **kwargs):
# Let ExtensionArray._reduce raise the TypeError
return super()._reduce(name, skipna=skipna, **kwargs)

# GH51624: pyarrow defaults to min_count=1, pandas behavior is min_count=0
if name in ["any", "all"] and "min_count" not in kwargs:
kwargs["min_count"] = 0

try:
result = pyarrow_meth(data_to_reduce, skip_nulls=skipna, **kwargs)
except (AttributeError, NotImplementedError, TypeError) as err:
Expand Down
16 changes: 10 additions & 6 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2328,9 +2328,13 @@ def test_dt_tz_localize(unit):
tm.assert_series_equal(result, expected)


def test_concat_empty_arrow_backed_series(dtype):
# GH#51734
ser = pd.Series([], dtype=dtype)
expected = ser.copy()
result = pd.concat([ser[np.array([], dtype=np.bool_)]])
tm.assert_series_equal(result, expected)
@pytest.mark.parametrize("skipna", [True, False])
def test_boolean_reduce_series_all_null(all_boolean_reductions, skipna):
# GH51624
ser = pd.Series([None], dtype="float64[pyarrow]")
result = getattr(ser, all_boolean_reductions)(skipna=skipna)
if skipna:
expected = all_boolean_reductions == "all"
else:
expected = pd.NA
assert result is expected