Skip to content

Commit e180289

Browse files
committed
Add test_agg_with_unhashable_name_colum_value (should fail)
1 parent d3f1426 commit e180289

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
@@ -1131,6 +1131,22 @@ def test_demo(self):
11311131
)
11321132
tm.assert_frame_equal(result.reindex_like(expected), expected)
11331133

1134+
def test_agg_with_unhashable_name_column_value(self):
1135+
#GH 36212 - Column name is "name"
1136+
data = {'name': ['foo', 'bar']}
1137+
df = pd.DataFrame(data)
1138+
1139+
#result's name should be None
1140+
result = df.agg({'name': 'count'})
1141+
expected = pd.Series({'name':2})
1142+
tm.assert_series_equal(result, expected)
1143+
1144+
#Check if name is preserved when aggregating series instead
1145+
result = df['name'].agg({'name':'count'})
1146+
expected = pd.Series({'name':2}, name='name')
1147+
tm.assert_series_equal(result, expected)
1148+
1149+
11341150
def test_agg_multiple_mixed_no_warning(self):
11351151
# GH 20909
11361152
mdf = pd.DataFrame(

0 commit comments

Comments
 (0)