Skip to content

Commit d1792d9

Browse files
committed
Add code for Categorical to convert/unconvert
1 parent 2a4bd6a commit d1792d9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/io/packers.py

+6
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ def convert(values):
265265
v = values.ravel()
266266

267267
# convert object
268+
if is_categorical_dtype(values):
269+
return v
270+
268271
if dtype == np.object_:
269272
return v.tolist()
270273

@@ -301,6 +304,9 @@ def unconvert(values, dtype, compress=None):
301304
if as_is_ext:
302305
values = values.data
303306

307+
if is_categorical_dtype(dtype):
308+
return values
309+
304310
if dtype == np.object_:
305311
return np.array(values, dtype=object)
306312

0 commit comments

Comments
 (0)