File tree 2 files changed +5
-6
lines changed
2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -471,12 +471,11 @@ def is_any_frame() -> bool:
471
471
try :
472
472
result = DataFrame (result )
473
473
except ValueError :
474
-
475
474
# we have a dict of scalars
476
475
477
- name = getattr ( self , "name" , None )
478
- name = name if is_hashable ( name ) else None
479
- # GH 36212
476
+ # GH 36212 use name only if self is a series
477
+ name = getattr ( self , " name" , None ) if ( self . ndim == 1 ) else None
478
+
480
479
result = Series (result , name = name )
481
480
482
481
return result , True
Original file line number Diff line number Diff line change @@ -1147,7 +1147,7 @@ def test_demo(self):
1147
1147
)
1148
1148
tm .assert_frame_equal (result .reindex_like (expected ), expected )
1149
1149
1150
- def test_agg_with_unhashable_name_column_value (self ):
1150
+ def test_agg_with_name_as_column_name (self ):
1151
1151
# GH 36212 - Column name is "name"
1152
1152
data = {"name" : ["foo" , "bar" ]}
1153
1153
df = pd .DataFrame (data )
@@ -1157,7 +1157,7 @@ def test_agg_with_unhashable_name_column_value(self):
1157
1157
expected = pd .Series ({"name" : 2 })
1158
1158
tm .assert_series_equal (result , expected )
1159
1159
1160
- # Check if name is preserved when aggregating series instead
1160
+ # Check if name is still preserved when aggregating series instead
1161
1161
result = df ["name" ].agg ({"name" : "count" })
1162
1162
expected = pd .Series ({"name" : 2 }, name = "name" )
1163
1163
tm .assert_series_equal (result , expected )
You can’t perform that action at this time.
0 commit comments