Skip to content

Commit c3c04e2

Browse files
gfyoungjreback
authored andcommitted
CLN: Remove Categorical.from_array (pandas-dev#18642)
Deprecated in 0.19.0 xref pandas-devgh-13854.
1 parent 52838e6 commit c3c04e2

File tree

3 files changed

+2
-26
lines changed

3 files changed

+2
-26
lines changed

doc/source/whatsnew/v0.22.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ Removal of prior version deprecations/changes
149149
- ``pd.ordered_merge`` has been removed (deprecated since v0.19). Use ``pd.merge_ordered`` instead (:issue:`18459`)
150150
- The ``SparseList`` class has been removed (:issue:`14007`)
151151
- The ``pandas.io.wb`` and ``pandas.io.data`` stub modules have been removed (:issue:`13735`)
152+
- ``Categorical.from_array`` has been removed (:issue:`13854`)
152153

153154
.. _whatsnew_0220.performance:
154155

pandas/core/categorical.py

-20
Original file line numberDiff line numberDiff line change
@@ -552,26 +552,6 @@ def _from_inferred_categories(cls, inferred_categories, inferred_codes,
552552

553553
return cls(codes, dtype=dtype, fastpath=True)
554554

555-
@classmethod
556-
def from_array(cls, data, **kwargs):
557-
"""
558-
.. deprecated:: 0.19.0
559-
Use ``Categorical`` instead.
560-
561-
Make a Categorical type from a single array-like object.
562-
563-
For internal compatibility with numpy arrays.
564-
565-
Parameters
566-
----------
567-
data : array-like
568-
Can be an Index or array-like. The categories are assumed to be
569-
the unique values of `data`.
570-
"""
571-
warn("Categorical.from_array is deprecated, use Categorical instead",
572-
FutureWarning, stacklevel=2)
573-
return cls(data, **kwargs)
574-
575555
@classmethod
576556
def from_codes(cls, codes, categories, ordered=False):
577557
"""

pandas/tests/test_categorical.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1955,11 +1955,6 @@ def test_deprecated_labels(self):
19551955
res = cat.labels
19561956
tm.assert_numpy_array_equal(res, exp)
19571957

1958-
def test_deprecated_from_array(self):
1959-
# GH13854, `.from_array` is deprecated
1960-
with tm.assert_produces_warning(FutureWarning):
1961-
Categorical.from_array([0, 1])
1962-
19631958
def test_datetime_categorical_comparison(self):
19641959
dt_cat = Categorical(date_range('2014-01-01', periods=3), ordered=True)
19651960
tm.assert_numpy_array_equal(dt_cat > dt_cat[0],
@@ -4817,7 +4812,7 @@ def test_constructor(self):
48174812
assert isinstance(sc, tm.SubclassedCategorical)
48184813
tm.assert_categorical_equal(sc, Categorical(['a', 'b', 'c']))
48194814

4820-
def test_from_array(self):
4815+
def test_from_codes(self):
48214816
sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ['a', 'b', 'c'])
48224817
assert isinstance(sc, tm.SubclassedCategorical)
48234818
exp = Categorical.from_codes([1, 0, 2], ['a', 'b', 'c'])

0 commit comments

Comments
 (0)