Skip to content

Commit 3406547

Browse files
Pradyumna ReddyTomAugspurger
Pradyumna Reddy
authored andcommitted
bug fix #16524
1 parent 10c17d4 commit 3406547

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Conversion
5757

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

6162

6263
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

+9
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,12 @@ 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+
# see gh-16524: test conversion of Series to Categorical
254+
series = Series(['a', 'b', 'c'])
255+
256+
result = Series(series, dtype='category')
257+
expected = Series(['a', 'b', 'c'], dtype='category')
258+
259+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)