From 4f85eb8d0599cbea8c329eb7f48c6f188ea96a48 Mon Sep 17 00:00:00 2001 From: Terji Petersen Date: Mon, 4 Nov 2019 19:58:47 +0000 Subject: [PATCH] API: drop kwargs from Series.dropna, add explicit `how` parameter (#29388) --- doc/source/whatsnew/v1.0.0.rst | 2 ++ pandas/core/series.py | 12 +++--------- 2 files changed, 5 insertions(+), 9 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..7b65816dc06b9 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,8 +4608,8 @@ 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 - Not in use. + how : str, optional + Not in use. Kept for compatibility. 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)