Skip to content

Commit

Permalink
bug fix #16524
Browse files Browse the repository at this point in the history
  • Loading branch information
preddy5 committed Jun 2, 2017
1 parent fb47ee5 commit 83dd40a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Conversion

- Bug in ``pd.to_numeric()`` in which empty data inputs were causing Python to crash (:issue:`16302`)
- Silence numpy warnings when broadcasting DataFrame to Series with comparison ops (:issue:`16378`, :issue:`16306`)
- Bug in ``Series`` with dtype='category' (:issue:`16524`)


Indexing
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ class Categorical(PandasObject):
__array_priority__ = 1000
_typ = 'categorical'

def __init__(self, values, categories=None, ordered=False, fastpath=False):
def __init__(self, values, categories=None, ordered=False, fastpath=False,
**kwargs):

self._validate_ordered(ordered)

Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,11 @@ def test_intercept_astype_object(self):

result = df.values.squeeze()
assert (result[:, 0] == expected.values).all()

def test_series_to_categorical(self):
series = Series(['a', 'b', 'c'])

categorical_series = Series(series, dtype='category')
expected = Series(['a', 'b', 'c'], dtype='category')

tm.assert_series_equal(categorical_series, expected)

0 comments on commit 83dd40a

Please sign in to comment.