Skip to content

Commit 4cb91de

Browse files
jiawei-zhang-aim-vinicius
authored and
im-vinicius
committed
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 8597971 commit 4cb91de

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

doc/source/whatsnew/v2.1.0.rst

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ Styler
426426
- Bug in :meth:`Styler._copy` calling overridden methods in subclasses of :class:`Styler` (:issue:`52728`)
427427
-
428428

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

pandas/core/frame.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11044,7 +11044,8 @@ def std(
1104411044
numeric_only: bool = False,
1104511045
**kwargs,
1104611046
):
11047-
return super().std(axis, skipna, ddof, numeric_only, **kwargs)
11047+
result = cast(Series, super().std(axis, skipna, ddof, numeric_only, **kwargs))
11048+
return result.__finalize__(self, method="std")
1104811049

1104911050
@doc(make_doc("skew", ndim=2))
1105011051
def skew(

pandas/tests/generic/test_finalize.py

-1
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)