Skip to content

Commit d859ecc

Browse files
authored
TST: GH50347 create test for groupby sum of boolean values. (#50488)
1 parent 42b0b7a commit d859ecc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/groupby/test_groupby.py

+10
Original file line numberDiff line numberDiff line change
@@ -2828,3 +2828,13 @@ def test_groupby_index_name_in_index_content(val_in, index, val_out):
28282828
result = series.to_frame().groupby("blah").sum()
28292829
expected = expected.to_frame()
28302830
tm.assert_frame_equal(result, expected)
2831+
2832+
2833+
@pytest.mark.parametrize("n", [1, 10, 32, 100, 1000])
2834+
def test_sum_of_booleans(n):
2835+
# GH 50347
2836+
df = DataFrame({"groupby_col": 1, "bool": [True] * n})
2837+
df["bool"] = df["bool"].eq(True)
2838+
result = df.groupby("groupby_col").sum()
2839+
expected = DataFrame({"bool": [n]}, index=Index([1], name="groupby_col"))
2840+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)