Converting Series to categorical · Issue #16524 · pandas-dev/pandas (original) (raw)
TypeError Traceback (most recent call last) in () ----> 1 pd.Series(pd.Series(['a', 'b', 'c']), dtype='category')
/Users/ttylec/.virtualenvs/zettafox/lib/python3.6/site-packages/pandas/core/series.py in init(self, data, index, dtype, name, copy, fastpath) 241 if dtype is not None: 242 data = data.astype(dtype=dtype, raise_on_error=False, --> 243 copy=copy) 244 elif copy: 245 data = data.copy()
/Users/ttylec/.virtualenvs/zettafox/lib/python3.6/site-packages/pandas/core/internals.py in astype(self, dtype, **kwargs) 3222 3223 def astype(self, dtype, **kwargs): -> 3224 return self.apply('astype', dtype=dtype, **kwargs) 3225 3226 def convert(self, **kwargs):
/Users/ttylec/.virtualenvs/zettafox/lib/python3.6/site-packages/pandas/core/internals.py in apply(self, f, axes, filter, do_integrity_check, consolidate, **kwargs) 3089 3090 kwargs['mgr'] = self -> 3091 applied = getattr(b, f)(**kwargs) 3092 result_blocks = _extend_blocks(applied, result_blocks) 3093
/Users/ttylec/.virtualenvs/zettafox/lib/python3.6/site-packages/pandas/core/internals.py in astype(self, dtype, copy, errors, values, **kwargs) 469 def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs): 470 return self._astype(dtype, copy=copy, errors=errors, values=values, --> 471 **kwargs) 472 473 def _astype(self, dtype, copy=False, errors='raise', values=None,
/Users/ttylec/.virtualenvs/zettafox/lib/python3.6/site-packages/pandas/core/internals.py in _astype(self, dtype, copy, errors, values, klass, mgr, **kwargs) 488 # this is only called for non-categoricals 489 if self.is_categorical_astype(dtype): --> 490 return self.make_block(Categorical(self.values, **kwargs)) 491 492 # astype processing
TypeError: init() got an unexpected keyword argument 'raise_on_error'
When using simple list or np.array instead of pd.Series, it work. Doing .astype('category')
also works.