From 42813e10c1e809915ded5bff5d5eff78d22ca9a5 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Fri, 23 Oct 2020 20:53:47 -0500 Subject: [PATCH 1/9] ENH: propogate metadata on append --- pandas/core/frame.py | 4 ++-- pandas/tests/generic/test_finalize.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 801307a8f9481..d1aa72eade11d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7867,12 +7867,12 @@ def append( to_concat = [self, *other] else: to_concat = [self, other] - return concat( + return (concat( to_concat, ignore_index=ignore_index, verify_integrity=verify_integrity, sort=sort, - ) + )).__finalize__(self, method="append") def join( self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 42bd2c9a64901..f9b2083a27537 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -203,7 +203,7 @@ frame_data, operator.methodcaller("append", pd.DataFrame({"A": [1]})), ), - marks=not_implemented_mark, + #marks=not_implemented_mark, ), pytest.param( ( @@ -211,7 +211,7 @@ frame_data, operator.methodcaller("append", pd.DataFrame({"B": [1]})), ), - marks=not_implemented_mark, + #marks=not_implemented_mark, ), pytest.param( ( From fadcd7a48471b18650e06c105db09bf3052d7bb8 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Sat, 24 Oct 2020 09:46:01 -0500 Subject: [PATCH 2/9] ENH: metadata on merge, eval, diff, applymap, update --- pandas/core/frame.py | 10 +++++----- pandas/tests/generic/test_finalize.py | 19 ++++++------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d1aa72eade11d..a1b622989609c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3498,7 +3498,7 @@ def eval(self, expr, inplace=False, **kwargs): kwargs["target"] = self kwargs["resolvers"] = kwargs.get("resolvers", ()) + tuple(resolvers) - return _eval(expr, inplace=inplace, **kwargs) + return _eval(expr, inplace=inplace, **kwargs).__finalize__(self,"eval") def select_dtypes(self, include=None, exclude=None) -> DataFrame: """ @@ -6488,7 +6488,7 @@ def update( continue self[col] = expressions.where(mask, this, that) - + self.__finalize__(self,"update") # ---------------------------------------------------------------------- # Data reshaping @Appender( @@ -7351,7 +7351,7 @@ def diff(self, periods: int = 1, axis: Axis = 0) -> DataFrame: return self - self.shift(periods, axis=axis) new_data = self._mgr.diff(n=periods, axis=bm_axis) - return self._constructor(new_data) + return self._constructor(new_data).__finalize__(self,"diff") # ---------------------------------------------------------------------- # Function application @@ -7730,7 +7730,7 @@ def infer(x): return lib.map_infer(x, func, ignore_na=ignore_na) return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na) - return self.apply(infer) + return self.apply(infer).__finalize__(self,"applymap") # ---------------------------------------------------------------------- # Merging / joining methods @@ -8084,7 +8084,7 @@ def merge( copy=copy, indicator=indicator, validate=validate, - ) + ).__finalize__(self,method="merge") def round(self, decimals=0, *args, **kwargs) -> DataFrame: """ diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index f9b2083a27537..ba443c7f1a2c7 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -94,8 +94,7 @@ (pd.DataFrame, ({("A", "a"): [1]},), operator.methodcaller("__getitem__", ["A"])), (pd.DataFrame, frame_data, operator.methodcaller("query", "A == 1")), pytest.param( - (pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1")), - marks=not_implemented_mark, + (pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1")) ), (pd.DataFrame, frame_data, operator.methodcaller("select_dtypes", include="int")), (pd.DataFrame, frame_data, operator.methodcaller("assign", b=1)), @@ -155,7 +154,6 @@ frame_data, operator.methodcaller("update", pd.DataFrame(*frame_data)), ), - marks=not_implemented_mark, ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("pivot", columns="A")), @@ -190,20 +188,17 @@ marks=not_implemented_mark, ), pytest.param( - (pd.DataFrame, frame_data, operator.methodcaller("diff")), - marks=not_implemented_mark, - ), + (pd.DataFrame, frame_data, operator.methodcaller("diff")) + ), pytest.param( - (pd.DataFrame, frame_data, operator.methodcaller("applymap", lambda x: x)), - marks=not_implemented_mark, + (pd.DataFrame, frame_data, operator.methodcaller("applymap", lambda x: x)) ), pytest.param( ( pd.DataFrame, frame_data, operator.methodcaller("append", pd.DataFrame({"A": [1]})), - ), - #marks=not_implemented_mark, + ) ), pytest.param( ( @@ -211,15 +206,13 @@ frame_data, operator.methodcaller("append", pd.DataFrame({"B": [1]})), ), - #marks=not_implemented_mark, ), pytest.param( ( pd.DataFrame, frame_data, operator.methodcaller("merge", pd.DataFrame({"A": [1]})), - ), - marks=not_implemented_mark, + ) ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("round", 2)), From a59732aa222e8359687ae3d256e5a1842856171f Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Mon, 26 Oct 2020 11:48:12 -0500 Subject: [PATCH 3/9] added travis integration and ran black pandas --- pandas/core/frame.py | 25 ++++++++++++++----------- pandas/tests/generic/test_finalize.py | 8 ++------ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 539e7435f7ca0..3b992b297bb77 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3513,7 +3513,7 @@ def eval(self, expr, inplace=False, **kwargs): kwargs["target"] = self kwargs["resolvers"] = kwargs.get("resolvers", ()) + tuple(resolvers) - return _eval(expr, inplace=inplace, **kwargs).__finalize__(self,"eval") + return _eval(expr, inplace=inplace, **kwargs).__finalize__(self, "eval") def select_dtypes(self, include=None, exclude=None) -> DataFrame: """ @@ -6528,7 +6528,8 @@ def update( continue self[col] = expressions.where(mask, this, that) - self.__finalize__(self,"update") + self.__finalize__(self, "update") + # ---------------------------------------------------------------------- # Data reshaping @Appender( @@ -7393,7 +7394,7 @@ def diff(self, periods: int = 1, axis: Axis = 0) -> DataFrame: return self - self.shift(periods, axis=axis) new_data = self._mgr.diff(n=periods, axis=bm_axis) - return self._constructor(new_data).__finalize__(self,"diff") + return self._constructor(new_data).__finalize__(self, "diff") # ---------------------------------------------------------------------- # Function application @@ -7772,7 +7773,7 @@ def infer(x): return lib.map_infer(x, func, ignore_na=ignore_na) return lib.map_infer(x.astype(object)._values, func, ignore_na=ignore_na) - return self.apply(infer).__finalize__(self,"applymap") + return self.apply(infer).__finalize__(self, "applymap") # ---------------------------------------------------------------------- # Merging / joining methods @@ -7909,12 +7910,14 @@ def append( to_concat = [self, *other] else: to_concat = [self, other] - return (concat( - to_concat, - ignore_index=ignore_index, - verify_integrity=verify_integrity, - sort=sort, - )).__finalize__(self, method="append") + return ( + concat( + to_concat, + ignore_index=ignore_index, + verify_integrity=verify_integrity, + sort=sort, + ) + ).__finalize__(self, method="append") def join( self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False @@ -8126,7 +8129,7 @@ def merge( copy=copy, indicator=indicator, validate=validate, - ).__finalize__(self,method="merge") + ).__finalize__(self, method="merge") def round(self, decimals=0, *args, **kwargs) -> DataFrame: """ diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 3db360515dc53..10fadc818f6e6 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -93,9 +93,7 @@ (pd.DataFrame, frame_data, operator.methodcaller("__getitem__", np.array([True]))), (pd.DataFrame, ({("A", "a"): [1]},), operator.methodcaller("__getitem__", ["A"])), (pd.DataFrame, frame_data, operator.methodcaller("query", "A == 1")), - pytest.param( - (pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1")) - ), + pytest.param((pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1"))), (pd.DataFrame, frame_data, operator.methodcaller("select_dtypes", include="int")), (pd.DataFrame, frame_data, operator.methodcaller("assign", b=1)), (pd.DataFrame, frame_data, operator.methodcaller("set_axis", ["A"])), @@ -175,9 +173,7 @@ ), marks=not_implemented_mark, ), - pytest.param( - (pd.DataFrame, frame_data, operator.methodcaller("diff")) - ), + pytest.param((pd.DataFrame, frame_data, operator.methodcaller("diff"))), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("applymap", lambda x: x)) ), From 6370fb3a8ac6f561f0e1ea5af54f7c1c91e9d5d5 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Mon, 26 Oct 2020 18:46:01 +0000 Subject: [PATCH 4/9] removed __finalize__ in eval, added to whatsnew --- doc/source/whatsnew/v1.2.0.rst | 2 +- pandas/core/frame.py | 53 +++++++++++++++------------ pandas/tests/generic/test_finalize.py | 6 ++- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index 86211ea97e0bf..8097736af97a4 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -531,7 +531,7 @@ Other - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` incorrectly raising ``AssertionError`` instead of ``ValueError`` when invalid parameter combinations are passed (:issue:`36045`) - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` with numeric values and string ``to_replace`` (:issue:`34789`) - Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (:issue:`37037`) -- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` methods (:issue:`28283`) +- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` methods (:issue:`28283`) and :class:`DataFrame.append` and :class:`DataFrame.merge` and :class:`DataFrame.diff` and :class:`DataFrame.applymap` and :class:`DataFrame.update` - Bug in :meth:`Index.union` behaving differently depending on whether operand is a :class:`Index` or other list-like (:issue:`36384`) - Passing an array with 2 or more dimensions to the :class:`Series` constructor now raises the more specific ``ValueError``, from a bare ``Exception`` previously (:issue:`35744`) - Bug in ``accessor.DirNamesMixin``, where ``dir(obj)`` wouldn't show attributes defined on the instance (:issue:`37173`). diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 3b992b297bb77..46a7061dce538 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -3513,7 +3513,7 @@ def eval(self, expr, inplace=False, **kwargs): kwargs["target"] = self kwargs["resolvers"] = kwargs.get("resolvers", ()) + tuple(resolvers) - return _eval(expr, inplace=inplace, **kwargs).__finalize__(self, "eval") + return _eval(expr, inplace=inplace, **kwargs) def select_dtypes(self, include=None, exclude=None) -> DataFrame: """ @@ -6528,7 +6528,6 @@ def update( continue self[col] = expressions.where(mask, this, that) - self.__finalize__(self, "update") # ---------------------------------------------------------------------- # Data reshaping @@ -7911,13 +7910,17 @@ def append( else: to_concat = [self, other] return ( - concat( - to_concat, - ignore_index=ignore_index, - verify_integrity=verify_integrity, - sort=sort, + ( + concat( + to_concat, + ignore_index=ignore_index, + verify_integrity=verify_integrity, + sort=sort, + ) ) - ).__finalize__(self, method="append") + .__finalize__(self) + .__finalize__(other, method="append") + ) def join( self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False @@ -8115,21 +8118,25 @@ def merge( ) -> DataFrame: from pandas.core.reshape.merge import merge - return merge( - self, - right, - how=how, - on=on, - left_on=left_on, - right_on=right_on, - left_index=left_index, - right_index=right_index, - sort=sort, - suffixes=suffixes, - copy=copy, - indicator=indicator, - validate=validate, - ).__finalize__(self, method="merge") + return ( + merge( + self, + right, + how=how, + on=on, + left_on=left_on, + right_on=right_on, + left_index=left_index, + right_index=right_index, + sort=sort, + suffixes=suffixes, + copy=copy, + indicator=indicator, + validate=validate, + ) + .__finalize__(self) + .__finalize__(right, method="merge") + ) def round(self, decimals=0, *args, **kwargs) -> DataFrame: """ diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index 10fadc818f6e6..c628811736ec3 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -93,7 +93,10 @@ (pd.DataFrame, frame_data, operator.methodcaller("__getitem__", np.array([True]))), (pd.DataFrame, ({("A", "a"): [1]},), operator.methodcaller("__getitem__", ["A"])), (pd.DataFrame, frame_data, operator.methodcaller("query", "A == 1")), - pytest.param((pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1"))), + pytest.param( + (pd.DataFrame, frame_data, operator.methodcaller("eval", "A + 1")), + marks=not_implemented_mark, + ), (pd.DataFrame, frame_data, operator.methodcaller("select_dtypes", include="int")), (pd.DataFrame, frame_data, operator.methodcaller("assign", b=1)), (pd.DataFrame, frame_data, operator.methodcaller("set_axis", ["A"])), @@ -149,6 +152,7 @@ frame_data, operator.methodcaller("update", pd.DataFrame(*frame_data)), ), + marks=not_implemented_mark, ), (pd.DataFrame, frame_data, operator.methodcaller("pivot", columns="A")), pytest.param( From d6943597aca79185ccf5fef5521a2ad784b9effe Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Tue, 27 Oct 2020 00:04:19 +0000 Subject: [PATCH 5/9] fixed issue in merge --- pandas/core/frame.py | 32 +++++++++++++----------------- pandas/core/reshape/merge.py | 2 +- pandas/tests/generic/test_frame.py | 1 + 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 46a7061dce538..7ca8d8f6b881e 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -8118,24 +8118,20 @@ def merge( ) -> DataFrame: from pandas.core.reshape.merge import merge - return ( - merge( - self, - right, - how=how, - on=on, - left_on=left_on, - right_on=right_on, - left_index=left_index, - right_index=right_index, - sort=sort, - suffixes=suffixes, - copy=copy, - indicator=indicator, - validate=validate, - ) - .__finalize__(self) - .__finalize__(right, method="merge") + return merge( + self, + right, + how=how, + on=on, + left_on=left_on, + right_on=right_on, + left_index=left_index, + right_index=right_index, + sort=sort, + suffixes=suffixes, + copy=copy, + indicator=indicator, + validate=validate, ) def round(self, decimals=0, *args, **kwargs) -> DataFrame: diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 5012be593820e..02576fee3cb40 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -689,7 +689,7 @@ def get_result(self): self._maybe_restore_index_levels(result) - return result + return result.__finalize__(self, method="merge") def _indicator_pre_merge( self, left: "DataFrame", right: "DataFrame" diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index 9ecc0e6194912..8544396103435 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -124,6 +124,7 @@ def finalize(self, other, method=None, **kwargs): DataFrame.__finalize__ = finalize result = df1.merge(df2, left_on=["a"], right_on=["c"], how="inner") + print(_metadata) assert result.filename == "fname1.csv|fname2.csv" # concat From ca8e621bdb2d434e377d917246b6a51ee16b6c29 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Tue, 27 Oct 2020 00:20:23 +0000 Subject: [PATCH 6/9] added suggested changes --- doc/source/whatsnew/v1.2.0.rst | 2 +- pandas/tests/generic/test_frame.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index 8097736af97a4..f04521def09b1 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -531,7 +531,7 @@ Other - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` incorrectly raising ``AssertionError`` instead of ``ValueError`` when invalid parameter combinations are passed (:issue:`36045`) - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` with numeric values and string ``to_replace`` (:issue:`34789`) - Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (:issue:`37037`) -- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` methods (:issue:`28283`) and :class:`DataFrame.append` and :class:`DataFrame.merge` and :class:`DataFrame.diff` and :class:`DataFrame.applymap` and :class:`DataFrame.update` +- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` and :class:`DataFrame.append` and :class:`DataFrame.merge` and :class:`DataFrame.diff` and :class:`DataFrame.applymap` and :class:`DataFrame.update` methods (:issue:`28283`) - Bug in :meth:`Index.union` behaving differently depending on whether operand is a :class:`Index` or other list-like (:issue:`36384`) - Passing an array with 2 or more dimensions to the :class:`Series` constructor now raises the more specific ``ValueError``, from a bare ``Exception`` previously (:issue:`35744`) - Bug in ``accessor.DirNamesMixin``, where ``dir(obj)`` wouldn't show attributes defined on the instance (:issue:`37173`). diff --git a/pandas/tests/generic/test_frame.py b/pandas/tests/generic/test_frame.py index 8544396103435..9ecc0e6194912 100644 --- a/pandas/tests/generic/test_frame.py +++ b/pandas/tests/generic/test_frame.py @@ -124,7 +124,6 @@ def finalize(self, other, method=None, **kwargs): DataFrame.__finalize__ = finalize result = df1.merge(df2, left_on=["a"], right_on=["c"], how="inner") - print(_metadata) assert result.filename == "fname1.csv|fname2.csv" # concat From c09d6dd451057db2b00ecb7ee5247a8a02791ad3 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Tue, 27 Oct 2020 13:45:04 +0000 Subject: [PATCH 7/9] removed merge --- pandas/core/reshape/merge.py | 2 +- pandas/tests/generic/test_finalize.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 02576fee3cb40..f9a65116f019a 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -1502,7 +1502,7 @@ def get_result(self): ) typ = self.left._constructor - result = typ(result_data).__finalize__(self, method=self._merge_type) + result = typ(result_data) self._maybe_add_join_keys(result, left_indexer, right_indexer) diff --git a/pandas/tests/generic/test_finalize.py b/pandas/tests/generic/test_finalize.py index c628811736ec3..f7caaf896a7d7 100644 --- a/pandas/tests/generic/test_finalize.py +++ b/pandas/tests/generic/test_finalize.py @@ -177,7 +177,6 @@ ), marks=not_implemented_mark, ), - pytest.param((pd.DataFrame, frame_data, operator.methodcaller("diff"))), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("applymap", lambda x: x)) ), @@ -200,7 +199,8 @@ pd.DataFrame, frame_data, operator.methodcaller("merge", pd.DataFrame({"A": [1]})), - ) + ), + marks=not_implemented_mark, ), pytest.param( (pd.DataFrame, frame_data, operator.methodcaller("round", 2)), From 395362b779de568dd3ed688f071cd4b73741b72d Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Tue, 3 Nov 2020 19:12:27 +0000 Subject: [PATCH 8/9] changed whats new and append --- doc/source/whatsnew/v1.2.0.rst | 2 +- pandas/core/frame.py | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index 9cf0685468f6f..669265dddd4ff 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -558,7 +558,7 @@ Other - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` incorrectly raising ``AssertionError`` instead of ``ValueError`` when invalid parameter combinations are passed (:issue:`36045`) - Bug in :meth:`DataFrame.replace` and :meth:`Series.replace` with numeric values and string ``to_replace`` (:issue:`34789`) - Fixed bug in metadata propagation incorrectly copying DataFrame columns as metadata when the column name overlaps with the metadata name (:issue:`37037`) -- Fixed metadata propagation in the :class:`Series.dt` and :class:`Series.str` accessors and :class:`DataFrame.duplicated` and :class:`DataFrame.stack` and :class:`DataFrame.unstack` and :class:`DataFrame.pivot` and :class:`DataFrame.append` and :class:`DataFrame.merge` and :class:`DataFrame.diff` and :class:`DataFrame.applymap` and :class:`DataFrame.update` methods (:issue:`28283`) +- Fixed metadata propagation in the :class:`Series.dt`, :class:`Series.str` accessors, :class:`DataFrame.duplicated`, :class:`DataFrame.stack`, :class:`DataFrame.unstack`, :class:`DataFrame.pivot`, :class:`DataFrame.append`, :class:`DataFrame.diff`, :class:`DataFrame.applymap` and :class:`DataFrame.update` methods (:issue:`28283`) (:issue:`37381`) - Bug in :meth:`Index.union` behaving differently depending on whether operand is a :class:`Index` or other list-like (:issue:`36384`) - Passing an array with 2 or more dimensions to the :class:`Series` constructor now raises the more specific ``ValueError``, from a bare ``Exception`` previously (:issue:`35744`) - Bug in ``accessor.DirNamesMixin``, where ``dir(obj)`` wouldn't show attributes defined on the instance (:issue:`37173`). diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 49b6524e3664c..c8e01e84f5f6a 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7918,17 +7918,13 @@ def append( else: to_concat = [self, other] return ( - ( - concat( - to_concat, - ignore_index=ignore_index, - verify_integrity=verify_integrity, - sort=sort, - ) + concat( + to_concat, + ignore_index=ignore_index, + verify_integrity=verify_integrity, + sort=sort, ) - .__finalize__(self) - .__finalize__(other, method="append") - ) + ).__finalize__(self) def join( self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False From 337b7cf35556e8e910c005ba2fc7f2b50314d191 Mon Sep 17 00:00:00 2001 From: Joel Whittier Date: Wed, 4 Nov 2020 15:29:03 +0000 Subject: [PATCH 9/9] added method name --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c8e01e84f5f6a..09a014af60861 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7924,7 +7924,7 @@ def append( verify_integrity=verify_integrity, sort=sort, ) - ).__finalize__(self) + ).__finalize__(self, method="append") def join( self, other, on=None, how="left", lsuffix="", rsuffix="", sort=False