From e8ceb92e70be0f31ec37d5bc93cb93bb18872e34 Mon Sep 17 00:00:00 2001 From: tp Date: Sun, 3 Nov 2019 21:47:57 +0000 Subject: [PATCH 1/2] API: drop kwargs from Series.dropna, add how parameter --- doc/source/whatsnew/v1.0.0.rst | 2 ++ pandas/core/series.py | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 101c5ec9137fc..8a481f194d408 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -192,6 +192,8 @@ Other API changes Now, pandas custom formatters will only be applied to plots created by pandas, through :meth:`~DataFrame.plot`. Previously, pandas' formatters would be applied to all plots created *after* a :meth:`~DataFrame.plot`. See :ref:`units registration ` for more. +- :meth:`Series.dropna` has dropped its ``**kwargs`` argument in favor of a single ``how`` parameter. + Supplying anything else than ``how`` to ``**kwargs`` raised a ``TypeError`` previously (:issue:`29388`) - diff --git a/pandas/core/series.py b/pandas/core/series.py index e57de0e69b366..45f8cf3bf2170 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4595,7 +4595,7 @@ def notna(self): def notnull(self): return super().notnull() - def dropna(self, axis=0, inplace=False, **kwargs): + def dropna(self, axis=0, inplace=False, how=None): """ Return a new Series with missing values removed. @@ -4608,7 +4608,7 @@ def dropna(self, axis=0, inplace=False, **kwargs): There is only one axis to drop values from. inplace : bool, default False If True, do operation inplace and return None. - **kwargs + how : str, optional Not in use. Returns @@ -4667,12 +4667,6 @@ def dropna(self, axis=0, inplace=False, **kwargs): dtype: object """ inplace = validate_bool_kwarg(inplace, "inplace") - kwargs.pop("how", None) - if kwargs: - raise TypeError( - "dropna() got an unexpected keyword " - 'argument "{0}"'.format(list(kwargs.keys())[0]) - ) # Validate the axis parameter self._get_axis_number(axis or 0) From 8a459573690bb2944168c1359c8142b1c4e9c856 Mon Sep 17 00:00:00 2001 From: tp Date: Sun, 3 Nov 2019 22:24:19 +0000 Subject: [PATCH 2/2] Add explanation for keeping how --- pandas/core/series.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 45f8cf3bf2170..7b65816dc06b9 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4609,7 +4609,7 @@ def dropna(self, axis=0, inplace=False, how=None): inplace : bool, default False If True, do operation inplace and return None. how : str, optional - Not in use. + Not in use. Kept for compatibility. Returns -------