Skip to content

Commit fe526ce

Browse files
jiawei-zhang-atopper-123
authored andcommitted
Fix the metadata propagation in Dataframe.std (pandas-dev#52924)
* 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
1 parent b37d689 commit fe526ce

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/source/whatsnew/v2.1.0.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ Styler
427427
- Bug in :meth:`Styler._copy` calling overridden methods in subclasses of :class:`Styler` (:issue:`52728`)
428428
-
429429

430+
Metadata
431+
^^^^^^^^
432+
- Fixed metadata propagation in :meth:`DataFrame.std` (:issue:`28283`)
433+
430434
Other
431435
^^^^^
432436
- Bug in :func:`assert_almost_equal` now throwing assertion error for two unequal sets (:issue:`51727`)

pandas/core/frame.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11060,7 +11060,8 @@ def std(
1106011060
numeric_only: bool = False,
1106111061
**kwargs,
1106211062
):
11063-
return super().std(axis, skipna, ddof, numeric_only, **kwargs)
11063+
result = cast(Series, super().std(axis, skipna, ddof, numeric_only, **kwargs))
11064+
return result.__finalize__(self, method="std")
1106411065

1106511066
@doc(make_doc("skew", ndim=2))
1106611067
def skew(

pandas/tests/generic/test_finalize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@
416416
),
417417
pytest.param(
418418
(pd.DataFrame, frame_data, operator.methodcaller("std")),
419-
marks=not_implemented_mark,
420419
),
421420
pytest.param(
422421
(pd.DataFrame, frame_data, operator.methodcaller("mean")),

0 commit comments

Comments
 (0)