Skip to content

Commit

Permalink
14873: test for groupby.agg coercing booleans (pandas-dev#25327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam Rana authored and Pingviinituutti committed Feb 28, 2019
1 parent 9f140c9 commit b21b80c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pandas/tests/groupby/aggregate/test_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,20 @@ def test_multi_function_flexible_mix(df):
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
result = grouped.aggregate(d)
tm.assert_frame_equal(result, expected)


def test_groupby_agg_coercing_bools():
# issue 14873
dat = pd.DataFrame(
{'a': [1, 1, 2, 2], 'b': [0, 1, 2, 3], 'c': [None, None, 1, 1]})
gp = dat.groupby('a')

index = Index([1, 2], name='a')

result = gp['b'].aggregate(lambda x: (x != 0).all())
expected = Series([False, True], index=index, name='b')
tm.assert_series_equal(result, expected)

result = gp['c'].aggregate(lambda x: x.isnull().all())
expected = Series([True, False], index=index, name='c')
tm.assert_series_equal(result, expected)

0 comments on commit b21b80c

Please sign in to comment.