Skip to content

Commit

Permalink
Test to_dummies column type cast
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed May 29, 2020
1 parent a1ab12b commit 5ae8517
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pandas/tests/arrays/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,18 @@ def test_remove_unused_categories(self):
)
def test_to_dummies(self, vals):
# GH 8745
cats = Categorical(vals)
cats = Categorical(Series(vals))
tm.assert_equal(cats.to_dummies(), get_dummies(cats).astype(bool))

def test_to_dummies_na_dtype(self):
# when dtype of NA column name != dtype of categories,
# check the cast to object
# GH 8745
cats = Categorical([1, 2, 2, 1, np.nan])
assert cats.dtype != object
dummies = cats.to_dummies(na_column="other")
assert dummies.columns.categories.dtype == object


class TestCategoricalAPIWithFactor(TestCategorical):
def test_describe(self):
Expand Down

0 comments on commit 5ae8517

Please sign in to comment.