Skip to content

Commit c7b416b

Browse files
committed
Pickling working
1 parent a7c2985 commit c7b416b

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

pandas/core/categorical.py

-7
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,6 @@ def __init__(self, values, categories=None, ordered=False, fastpath=False):
345345
self._dtype = dtype
346346
self._codes = coerce_indexer_dtype(codes, dtype.categories)
347347

348-
def __getstate__(self):
349-
# import pdb; pdb.set_trace()
350-
pass
351-
def __setstate__(self):
352-
# import pdb; pdb.set_trace()
353-
super().__setstate__()
354-
355348
@property
356349
def categories(self):
357350
return self.dtype.categories

pandas/core/dtypes/dtypes.py

+3
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ def __unicode__(self):
209209
def __repr__(self):
210210
return str(self)
211211

212+
def __getnewargs__(self):
213+
return (self.categories, self.ordered)
214+
212215
@staticmethod
213216
def _hash_categories(categories, ordered=True):
214217
from pandas.core.util.hashing import (

pandas/tests/dtypes/test_common.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,11 @@ def test_is_complex_dtype():
543543
(pd.Index([1, 2]), np.dtype('int64')),
544544
(pd.Index(['a', 'b']), np.dtype(object)),
545545
('category', 'category'),
546-
(pd.Categorical(['a', 'b']).dtype, CategoricalDtype()),
547-
(pd.Categorical(['a', 'b']), CategoricalDtype()),
548-
(pd.CategoricalIndex(['a', 'b']).dtype, CategoricalDtype()),
549-
(pd.CategoricalIndex(['a', 'b']), CategoricalDtype()),
546+
(pd.Categorical(['a', 'b']).dtype, CategoricalDtype(['a', 'b'])),
547+
(pd.Categorical(['a', 'b']), CategoricalDtype(['a', 'b'])),
548+
(pd.CategoricalIndex(['a', 'b']).dtype, CategoricalDtype(['a', 'b'])),
549+
(pd.CategoricalIndex(['a', 'b']), CategoricalDtype(['a', 'b'])),
550+
(CategoricalDtype(), CategoricalDtype()),
550551
(pd.DatetimeIndex([1, 2]), np.dtype('<M8[ns]')),
551552
(pd.DatetimeIndex([1, 2]).dtype, np.dtype('<M8[ns]')),
552553
('<M8[ns]', np.dtype('<M8[ns]')),

0 commit comments

Comments
 (0)