diff --git a/pandas/core/apply.py b/pandas/core/apply.py index 00b49c2f4f951..9ec0f7dca3b84 100644 --- a/pandas/core/apply.py +++ b/pandas/core/apply.py @@ -842,7 +842,7 @@ def apply_str(self) -> FrameOrSeriesUnion: # Special-cased because DataFrame.size returns a single scalar obj = self.obj value = obj.shape[self.axis] - return obj._constructor_sliced(value, index=self.agg_axis, name="size") + return obj._constructor_sliced(value, index=self.agg_axis) return super().apply_str() diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index 2511f6fc2563c..14266a2c29a7f 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -1279,9 +1279,9 @@ def test_size_as_str(how, axis): # on the columns result = getattr(df, how)("size", axis=axis) if axis == 0 or axis == "index": - expected = Series(df.shape[0], index=df.columns, name="size") + expected = Series(df.shape[0], index=df.columns) else: - expected = Series(df.shape[1], index=df.index, name="size") + expected = Series(df.shape[1], index=df.index) tm.assert_series_equal(result, expected)