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 1, 2017
1 parent fb47ee5 commit 27a955c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
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
11 changes: 10 additions & 1 deletion pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from numpy import nan
import numpy as np

from pandas import Series, Timestamp, Timedelta, DataFrame, date_range
from pandas import (Categorical, Series, Timestamp, Timedelta,
DataFrame, date_range)

from pandas.compat import lrange, range, u
from pandas import compat
Expand Down Expand Up @@ -248,3 +249,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 27a955c

Please sign in to comment.