Skip to content

Commit 6a9fb45

Browse files
devin-petersohnPingviinituutti
authored andcommitted
BUG: Fixing regression in DataFrame.all and DataFrame.any with bool_only=True (pandas-dev#25102)
1 parent 6cacfa9 commit 6a9fb45

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

doc/source/whatsnew/v0.24.2.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ including other versions of pandas.
2020
Fixed Regressions
2121
^^^^^^^^^^^^^^^^^
2222

23-
-
24-
-
25-
-
23+
- Fixed regression in :meth:`DataFrame.all` and :meth:`DataFrame.any` where ``bool_only=True`` was ignored (:issue:`25101`)
2624

2725
.. _whatsnew_0242.enhancements:
2826

pandas/core/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7498,7 +7498,8 @@ def f(x):
74987498
if filter_type is None or filter_type == 'numeric':
74997499
data = self._get_numeric_data()
75007500
elif filter_type == 'bool':
7501-
data = self
7501+
# GH 25101, # GH 24434
7502+
data = self._get_bool_data() if axis == 0 else self
75027503
else: # pragma: no cover
75037504
msg = ("Generating numeric_only data with filter_type {f}"
75047505
"not supported.".format(f=filter_type))

pandas/tests/frame/test_analytics.py

+20
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,26 @@ def test_any_datetime(self):
14421442
expected = Series([True, True, True, False])
14431443
tm.assert_series_equal(result, expected)
14441444

1445+
def test_any_all_bool_only(self):
1446+
1447+
# GH 25101
1448+
df = DataFrame({"col1": [1, 2, 3],
1449+
"col2": [4, 5, 6],
1450+
"col3": [None, None, None]})
1451+
1452+
result = df.all(bool_only=True)
1453+
expected = Series(dtype=np.bool)
1454+
tm.assert_series_equal(result, expected)
1455+
1456+
df = DataFrame({"col1": [1, 2, 3],
1457+
"col2": [4, 5, 6],
1458+
"col3": [None, None, None],
1459+
"col4": [False, False, True]})
1460+
1461+
result = df.all(bool_only=True)
1462+
expected = Series({"col4": False})
1463+
tm.assert_series_equal(result, expected)
1464+
14451465
@pytest.mark.parametrize('func, data, expected', [
14461466
(np.any, {}, False),
14471467
(np.all, {}, True),

0 commit comments

Comments
 (0)