Skip to content

Commit c3c4ffa

Browse files
Pradyumna ReddyPradyumna Reddy
Pradyumna Reddy
authored and
Pradyumna Reddy
committed
1 parent fbdae2d commit c3c4ffa

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Bug Fixes
4141
detecting the terminal size. This fix only applies to python 3 (:issue:`16496`)
4242
- Bug in using ``pathlib.Path`` or ``py.path.local`` objects with io functions (:issue:`16291`)
4343
- Bug in ``DataFrame.update()`` with ``overwrite=False`` and ``NaN values`` (:issue:`15593`)
44+
- Bug in ``Series`` with dtype='category' (:issue:`16524`)
4445

4546

4647

pandas/core/categorical.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ class Categorical(PandasObject):
248248
__array_priority__ = 1000
249249
_typ = 'categorical'
250250

251-
def __init__(self, values, categories=None, ordered=False, fastpath=False):
251+
def __init__(self, values, categories=None, ordered=False, fastpath=False,
252+
**kwargs):
252253

253254
self._validate_ordered(ordered)
254255

pandas/tests/series/test_dtypes.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from numpy import nan
1313
import numpy as np
1414

15-
from pandas import Series, Timestamp, Timedelta, DataFrame, date_range
15+
from pandas import (Categorical, Series, Timestamp, Timedelta,
16+
DataFrame, date_range)
1617

1718
from pandas.compat import lrange, range, u
1819
from pandas import compat
@@ -248,3 +249,11 @@ def test_intercept_astype_object(self):
248249

249250
result = df.values.squeeze()
250251
assert (result[:, 0] == expected.values).all()
252+
253+
def test_series_to_categorical(self):
254+
series = Series(['a', 'b', 'c'])
255+
256+
categorical_series = Series(series, dtype='category')
257+
expected = Categorical(['a', 'b', 'c'])
258+
259+
assert (categorical_series == expected).all()

0 commit comments

Comments
 (0)