From 26c2cad7dd08d3c0688e963845d8273ee93a46c3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sun, 16 Jul 2017 23:27:10 -0700 Subject: [PATCH] COMPAT: Add back remove_na for seaborn Closes gh-16971. --- pandas/core/dtypes/missing.py | 15 +++++++++++++++ pandas/core/series.py | 3 +++ pandas/tests/dtypes/test_missing.py | 8 +++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index 9913923cb7807d..135032b340650d 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -2,6 +2,8 @@ missing types & inference """ import numpy as np +import warnings + from pandas._libs import lib from pandas._libs.tslib import NaT, iNaT from .generic import (ABCMultiIndex, ABCSeries, @@ -401,3 +403,16 @@ def remove_na_arraylike(arr): Return array-like containing only true/non-NaN values, possibly empty. """ return arr[notnull(lib.values_from_object(arr))] + + +# see gh-16971 +def remove_na(arr): + """ + DEPRECATED : this function will be removed in a future version. + + Alias to `remove_na_arraylike` for `seaborn` compatibility. + """ + + warnings.warn("remove_na is deprecated. Use remove_na_arraylike instead.", + FutureWarning, stacklevel=2) + return remove_na_arraylike(arr) diff --git a/pandas/core/series.py b/pandas/core/series.py index 4d5b718ce0ae90..70e52330cba29b 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -38,6 +38,9 @@ maybe_cast_to_datetime, maybe_castable) from pandas.core.dtypes.missing import isnull, notnull, remove_na_arraylike +# see gh-16971 +from pandas.core.dtypes.missing import remove_na # noqa + from pandas.core.common import (is_bool_indexer, _default_index, _asarray_tuplesafe, diff --git a/pandas/tests/dtypes/test_missing.py b/pandas/tests/dtypes/test_missing.py index 90993890b75532..bff812ecfc150a 100644 --- a/pandas/tests/dtypes/test_missing.py +++ b/pandas/tests/dtypes/test_missing.py @@ -14,7 +14,13 @@ from pandas.core.dtypes.dtypes import DatetimeTZDtype from pandas.core.dtypes.missing import ( array_equivalent, isnull, notnull, - na_value_for_dtype) + na_value_for_dtype, remove_na) + + +def test_remove_na_deprecation(): + # see gh-16971 + with tm.assert_produces_warning(FutureWarning): + remove_na(Series([])) def test_notnull():