-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate categories and ordered parameters
- Loading branch information
1 parent
79a60b2
commit 8a6ec5d
Showing
16 changed files
with
113 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from pandas import Categorical | ||
from pandas.api.types import CategoricalDtype | ||
import pandas.util.testing as tm | ||
|
||
|
||
class TestCategoricalSubclassing(object): | ||
|
||
def test_constructor(self): | ||
sc = tm.SubclassedCategorical(['a', 'b', 'c']) | ||
assert isinstance(sc, tm.SubclassedCategorical) | ||
tm.assert_categorical_equal(sc, Categorical(['a', 'b', 'c'])) | ||
subclassed = tm.SubclassedCategorical(['a', 'b', 'c']) | ||
assert isinstance(subclassed, tm.SubclassedCategorical) | ||
tm.assert_categorical_equal(subclassed, Categorical(['a', 'b', 'c'])) | ||
|
||
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']) | ||
tm.assert_categorical_equal(sc, exp) | ||
dtype = CategoricalDtype(['a', 'b', 'c']) | ||
subclassed = tm.SubclassedCategorical.from_codes([1, 0, 2], | ||
dtype=dtype) | ||
assert isinstance(subclassed, tm.SubclassedCategorical) | ||
|
||
expected = Categorical.from_codes([1, 0, 2], dtype=dtype) | ||
tm.assert_categorical_equal(subclassed, expected) | ||
|
||
def test_map(self): | ||
sc = tm.SubclassedCategorical(['a', 'b', 'c']) | ||
res = sc.map(lambda x: x.upper()) | ||
assert isinstance(res, tm.SubclassedCategorical) | ||
exp = Categorical(['A', 'B', 'C']) | ||
tm.assert_categorical_equal(res, exp) | ||
subclassed = tm.SubclassedCategorical(['a', 'b', 'c']) | ||
result = subclassed.map(lambda x: x.upper()) | ||
assert isinstance(result, tm.SubclassedCategorical) | ||
expected = Categorical(['A', 'B', 'C']) | ||
tm.assert_categorical_equal(result, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.