Skip to content

Commit

Permalink
CLN: Remove Categorical.from_array (#18642)
Browse files Browse the repository at this point in the history
Deprecated in 0.19.0

xref gh-13854.
  • Loading branch information
gfyoung authored and jreback committed Dec 5, 2017
1 parent 52838e6 commit c3c04e2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.22.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Removal of prior version deprecations/changes
- ``pd.ordered_merge`` has been removed (deprecated since v0.19). Use ``pd.merge_ordered`` instead (:issue:`18459`)
- The ``SparseList`` class has been removed (:issue:`14007`)
- The ``pandas.io.wb`` and ``pandas.io.data`` stub modules have been removed (:issue:`13735`)
- ``Categorical.from_array`` has been removed (:issue:`13854`)

.. _whatsnew_0220.performance:

Expand Down
20 changes: 0 additions & 20 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,26 +552,6 @@ def _from_inferred_categories(cls, inferred_categories, inferred_codes,

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

@classmethod
def from_array(cls, data, **kwargs):
"""
.. deprecated:: 0.19.0
Use ``Categorical`` instead.
Make a Categorical type from a single array-like object.
For internal compatibility with numpy arrays.
Parameters
----------
data : array-like
Can be an Index or array-like. The categories are assumed to be
the unique values of `data`.
"""
warn("Categorical.from_array is deprecated, use Categorical instead",
FutureWarning, stacklevel=2)
return cls(data, **kwargs)

@classmethod
def from_codes(cls, codes, categories, ordered=False):
"""
Expand Down
7 changes: 1 addition & 6 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,11 +1955,6 @@ def test_deprecated_labels(self):
res = cat.labels
tm.assert_numpy_array_equal(res, exp)

def test_deprecated_from_array(self):
# GH13854, `.from_array` is deprecated
with tm.assert_produces_warning(FutureWarning):
Categorical.from_array([0, 1])

def test_datetime_categorical_comparison(self):
dt_cat = Categorical(date_range('2014-01-01', periods=3), ordered=True)
tm.assert_numpy_array_equal(dt_cat > dt_cat[0],
Expand Down Expand Up @@ -4817,7 +4812,7 @@ def test_constructor(self):
assert isinstance(sc, tm.SubclassedCategorical)
tm.assert_categorical_equal(sc, Categorical(['a', 'b', 'c']))

def test_from_array(self):
def test_from_codes(self):
sc = tm.SubclassedCategorical.from_codes([1, 0, 2], ['a', 'b', 'c'])
assert isinstance(sc, tm.SubclassedCategorical)
exp = Categorical.from_codes([1, 0, 2], ['a', 'b', 'c'])
Expand Down

0 comments on commit c3c04e2

Please sign in to comment.