Skip to content

Commit

Permalink
Fix the metadata propagation in Dataframe.std (pandas-dev#52924)
Browse files Browse the repository at this point in the history
* Fix the metadata propagation both in Dataframe.std

* Fix the typing problem by forcing propogation only on Series

* From judge statement  to cast

* Add whatsnew
  • Loading branch information
jiawei-zhang-a authored and topper-123 committed May 7, 2023
1 parent b37d689 commit fe526ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ Styler
- Bug in :meth:`Styler._copy` calling overridden methods in subclasses of :class:`Styler` (:issue:`52728`)
-

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`)
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -11060,7 +11060,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(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/generic/test_finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@
),
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("std")),
marks=not_implemented_mark,
),
pytest.param(
(pd.DataFrame, frame_data, operator.methodcaller("mean")),
Expand Down

0 comments on commit fe526ce

Please sign in to comment.