diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index cfce12c2930d7..328d6a5092b36 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -417,6 +417,10 @@ Styler - - +Metadata +^^^^^^^^ +- Fixed metadata propagation in :meth:`DataFrame.std` (:issue:`28283`) + Other ^^^^^ - Bug in :func:`assert_almost_equal` now throwing assertion error for two unequal sets (:issue:`51727`) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 838a34adeaf82..1c96f96a30fec 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -11069,7 +11069,8 @@ def std( numeric_only: bool = False, **kwargs, ): - return super().std(axis, skipna, ddof, numeric_only, **kwargs) + result = cast(Series, super().std(axis, skipna, ddof, numeric_only, **kwargs)) + return result.__finalize__(self, method="std") @doc(make_doc("skew", ndim=2)) def skew( diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index a76b6b94d719d..7403ba271663d 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -418,7 +418,6 @@ ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("std")), - marks=not_implemented_mark, ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("mean")),