Skip to content

Commit 26c2cad

Browse files
committed
COMPAT: Add back remove_na for seaborn
Closes gh-16971.
1 parent ea487fc commit 26c2cad

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

pandas/core/dtypes/missing.py

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
missing types & inference
33
"""
44
import numpy as np
5+
import warnings
6+
57
from pandas._libs import lib
68
from pandas._libs.tslib import NaT, iNaT
79
from .generic import (ABCMultiIndex, ABCSeries,
@@ -401,3 +403,16 @@ def remove_na_arraylike(arr):
401403
Return array-like containing only true/non-NaN values, possibly empty.
402404
"""
403405
return arr[notnull(lib.values_from_object(arr))]
406+
407+
408+
# see gh-16971
409+
def remove_na(arr):
410+
"""
411+
DEPRECATED : this function will be removed in a future version.
412+
413+
Alias to `remove_na_arraylike` for `seaborn` compatibility.
414+
"""
415+
416+
warnings.warn("remove_na is deprecated. Use remove_na_arraylike instead.",
417+
FutureWarning, stacklevel=2)
418+
return remove_na_arraylike(arr)

pandas/core/series.py

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
maybe_cast_to_datetime, maybe_castable)
3939
from pandas.core.dtypes.missing import isnull, notnull, remove_na_arraylike
4040

41+
# see gh-16971
42+
from pandas.core.dtypes.missing import remove_na # noqa
43+
4144
from pandas.core.common import (is_bool_indexer,
4245
_default_index,
4346
_asarray_tuplesafe,

pandas/tests/dtypes/test_missing.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
from pandas.core.dtypes.dtypes import DatetimeTZDtype
1515
from pandas.core.dtypes.missing import (
1616
array_equivalent, isnull, notnull,
17-
na_value_for_dtype)
17+
na_value_for_dtype, remove_na)
18+
19+
20+
def test_remove_na_deprecation():
21+
# see gh-16971
22+
with tm.assert_produces_warning(FutureWarning):
23+
remove_na(Series([]))
1824

1925

2026
def test_notnull():

0 commit comments

Comments
 (0)