File tree 3 files changed +4
-4
lines changed
3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -401,7 +401,8 @@ def _wrap_applied_output(
401
401
not_indexed_same = not_indexed_same ,
402
402
is_transform = is_transform ,
403
403
)
404
- result .name = self .obj .name
404
+ if isinstance (result , Series ):
405
+ result .name = self .obj .name
405
406
return result
406
407
else :
407
408
# GH #6265 #24880
Original file line number Diff line number Diff line change @@ -1177,8 +1177,7 @@ def reset_identity(values):
1177
1177
result = concat (values , axis = self .axis )
1178
1178
1179
1179
name = self .obj .name if self .obj .ndim == 1 else self ._selection
1180
- if isinstance (result , Series ) and name is not None :
1181
-
1180
+ if isinstance (result , Series ) and result .name is None and name is not None :
1182
1181
result .name = name
1183
1182
1184
1183
return result
Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ def f(piece):
334
334
result = grouped .apply (f )
335
335
336
336
assert isinstance (result , DataFrame )
337
+ assert not hasattr (result , "name" )
337
338
tm .assert_index_equal (result .index , ts .index )
338
339
339
340
@@ -1316,7 +1317,6 @@ def test_result_name_when_one_group(name):
1316
1317
ser = Series ([1 , 2 ], name = name )
1317
1318
result = ser .groupby (["a" , "a" ], group_keys = False ).apply (lambda x : x )
1318
1319
expected = Series ([1 , 2 ], name = name )
1319
-
1320
1320
tm .assert_series_equal (result , expected )
1321
1321
1322
1322
You can’t perform that action at this time.
0 commit comments