Skip to content

Commit a58de54

Browse files
author
Nicolai Reeve
committed
Addressing review comments from PR issue16916
1 parent 4c9e32d commit a58de54

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ Groupby/Resample/Rolling
174174
- Bug in ``DataFrame.resample().size()`` where an empty ``DataFrame`` did not return a ``Series`` (:issue:`14962`)
175175
- Bug in ``infer_freq`` causing indices with 2-day gaps during the working week to be wrongly inferred as business daily (:issue:`16624`)
176176
- Bug in ``.rolling.quantile()`` which incorrectly used different defaults than :func:`Series.quantile()` and :func:`DataFrame.quantile()` (:issue:`9413`, :issue:`16211`)
177+
- Bug in ``Grouper.aggregate()`` on using a mixed type grouping vector (:issue:`16916`)
177178

178179

179180
Sparse

pandas/tests/groupby/test_aggregate.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -894,13 +894,15 @@ def test_sum_uint64_overflow(self):
894894
tm.assert_frame_equal(result, expected)
895895

896896
def test_mixed_type_grouping(self):
897-
X = pd.DataFrame(data=[[[1, 1], [2, 2], [3, 3]],
898-
[[1, 1], [2, 2], [3, 3]]],
899-
columns=['X', 'Y', 'Z'],
900-
index=pd.Index(data=[2, 'g1'], name='grouping'))
901-
902-
S = pd.DataFrame(data=[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],
903-
columns=list('XYZ'), index=list('qwer'))
904-
S['grouping'] = ['g1', 'g1', 2, 2]
905-
T = S.groupby('grouping').aggregate(lambda x: x.tolist())
906-
tm.assert_frame_equal(T, X)
897+
# see gh-19616
898+
expected = pd.DataFrame(data=[[[1, 1], [2, 2], [3, 3]],
899+
[[1, 1], [2, 2], [3, 3]]],
900+
columns=['X', 'Y', 'Z'],
901+
index=pd.Index(data=[2, 'g1'],
902+
name='grouping'))
903+
904+
df = pd.DataFrame(data=[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],
905+
columns=list('XYZ'), index=list('qwer'))
906+
df['grouping'] = ['g1', 'g1', 2, 2]
907+
result = df.groupby('grouping').aggregate(lambda x: x.tolist())
908+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)