Skip to content

Commit 189fc61

Browse files
committed
Add test_agg_with_unhashable_name_colum_value (should fail)
1 parent 0d3c853 commit 189fc61

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/frame/apply/test_frame_apply.py

+16
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,22 @@ def test_demo(self):
11471147
)
11481148
tm.assert_frame_equal(result.reindex_like(expected), expected)
11491149

1150+
def test_agg_with_unhashable_name_column_value(self):
1151+
#GH 36212 - Column name is "name"
1152+
data = {'name': ['foo', 'bar']}
1153+
df = pd.DataFrame(data)
1154+
1155+
#result's name should be None
1156+
result = df.agg({'name': 'count'})
1157+
expected = pd.Series({'name':2})
1158+
tm.assert_series_equal(result, expected)
1159+
1160+
#Check if name is preserved when aggregating series instead
1161+
result = df['name'].agg({'name':'count'})
1162+
expected = pd.Series({'name':2}, name='name')
1163+
tm.assert_series_equal(result, expected)
1164+
1165+
11501166
def test_agg_multiple_mixed_no_warning(self):
11511167
# GH 20909
11521168
mdf = pd.DataFrame(

0 commit comments

Comments
 (0)