diff --git a/doc/source/release.rst b/doc/source/release.rst index e3eec9690e487..de9743bdc705a 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -409,6 +409,8 @@ See :ref:`Internal Refactoring` (:issue:`5189`, related :issue:`5004`) - ``MultiIndex`` constructor now validates that passed levels and labels are compatible. (:issue:`5213`, :issue:`5214`) + - Unity ``dropna`` for Series/DataFrame signature (:issue:`5250`), + tests from :issue:`5234`, courtesy of @rockg .. _release.bug_fixes-0.13.0: diff --git a/pandas/core/frame.py b/pandas/core/frame.py index d2d5776c4a67d..ece38e18e3688 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2459,8 +2459,6 @@ def dropna(self, axis=0, how='any', thresh=None, subset=None): return result axis = self._get_axis_number(axis) - if axis not in (0, 1): # pragma: no cover - raise AssertionError('axis must be 0 or 1') agg_axis = 1 - axis agg_obj = self diff --git a/pandas/core/panel.py b/pandas/core/panel.py index a86c186e26b53..f35070c634aa1 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -615,7 +615,7 @@ def _reindex_multi(self, axes, copy, fill_value): return Panel(new_values, items=new_items, major_axis=new_major, minor_axis=new_minor) - def dropna(self, axis=0, how='any'): + def dropna(self, axis=0, how='any', **kwargs): """ Drop 2D from panel, holding passed axis constant diff --git a/pandas/core/series.py b/pandas/core/series.py index 526355b0f4dc3..11033893b0b93 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2178,7 +2178,7 @@ def to_csv(self, path, index=True, sep=",", na_rep='', index_label=index_label, mode=mode, nanRep=nanRep, encoding=encoding, date_format=date_format) - def dropna(self): + def dropna(self, axis=0, **kwargs): """ Return Series without null values @@ -2186,6 +2186,7 @@ def dropna(self): ------- valid : Series """ + axis = self._get_axis_number(axis or 0) return remove_na(self) valid = lambda self: self.dropna() diff --git a/pandas/sparse/series.py b/pandas/sparse/series.py index 4d8b2578426ec..52d536fc16d37 100644 --- a/pandas/sparse/series.py +++ b/pandas/sparse/series.py @@ -569,11 +569,12 @@ def cumsum(self, axis=0, dtype=None, out=None): return self._constructor(new_array, index=self.index, sparse_index=new_array.sp_index).__finalize__(self) return Series(new_array, index=self.index).__finalize__(self) - def dropna(self): + def dropna(self, axis=0, **kwargs): """ Analogous to Series.dropna. If fill_value=NaN, returns a dense Series """ # TODO: make more efficient + axis = self._get_axis_number(axis or 0) dense_valid = self.to_dense().valid() if isnull(self.fill_value): return dense_valid diff --git a/pandas/stats/tests/test_ols.py b/pandas/stats/tests/test_ols.py index df2f545c90b92..69a101021f27d 100644 --- a/pandas/stats/tests/test_ols.py +++ b/pandas/stats/tests/test_ols.py @@ -379,6 +379,9 @@ def test_series_rhs(self): expected = ols(y=y, x={'x': x}) assert_series_equal(model.beta, expected.beta) + # GH 5233/5250 + assert_series_equal(model.y_predict, model.predict(x=x)) + def test_various_attributes(self): # just make sure everything "works". test correctness elsewhere diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index eb8969db9d15e..22bdb66b715ef 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -3550,6 +3550,9 @@ def test_dropna_empty(self): s = Series([]) self.assert_(len(s.dropna()) == 0) + # invalid axis + self.assertRaises(ValueError, s.dropna, axis=1) + def test_drop_duplicates(self): s = Series([1, 2, 3, 3])