Skip to content

Commit 80ed6da

Browse files
Pradyumna ReddyPradyumna Reddy
Pradyumna Reddy
authored and
Pradyumna Reddy
committed
bug fix #16524
1 parent ce3b0c3 commit 80ed6da

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Conversion
5959

6060
- Bug in :func:`to_numeric` in which empty data inputs were causing a segfault of the interpreter (:issue:`16302`)
6161
- Silence numpy warnings when broadcasting ``DataFrame`` to ``Series`` with comparison ops (:issue:`16378`, :issue:`16306`)
62+
- Bug in ``Series`` with ``dtype='category'`` (:issue:`16524`)
6263

6364

6465
Indexing

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs):
471471
**kwargs)
472472

473473
def _astype(self, dtype, copy=False, errors='raise', values=None,
474-
klass=None, mgr=None, **kwargs):
474+
klass=None, mgr=None, raise_on_error=False, **kwargs):
475475
"""
476476
Coerce to the new type (if copy=True, return a new copy)
477477
raise on an except if raise == True

pandas/tests/series/test_dtypes.py

+8
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,11 @@ def test_intercept_astype_object(self):
248248

249249
result = df.values.squeeze()
250250
assert (result[:, 0] == expected.values).all()
251+
252+
def test_series_to_categorical(self):
253+
series = Series(['a', 'b', 'c'])
254+
255+
result = Series(series, dtype='category')
256+
expected = Series(['a', 'b', 'c'], dtype='category')
257+
258+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)