def _set_categories(self, categories, fastpath=False):
    " Sets new categories inplace\n\n        Parameters\n        ----------\n        fastpath : boolean (default: False)\n           Don't perform validation of the categories for uniqueness or nulls\n\n        Examples\n        --------\n        >>> c = pd.Categorical(['a', 'b'])\n        >>> c\n        [a, b]\n        Categories (2, object): [a, b]\n\n        >>> c._set_categories(pd.Index(['a', 'c']))\n        >>> c\n        [a, c]\n        Categories (2, object): [a, c]\n        "
    if fastpath:
        new_dtype = CategoricalDtype._from_fastpath(categories, self.ordered)
    else:
        new_dtype = CategoricalDtype(categories, ordered=self.ordered)
    if ((not fastpath) and (self.dtype.categories is not None) and (len(new_dtype.categories) != len(self.dtype.categories))):
        raise ValueError('new categories need to have the same number of items than the old categories!')
    self._dtype = new_dtype
Sets new categories inplace

Parameters
----------
fastpath : boolean (default: False)
   Don't perform validation of the categories for uniqueness or nulls

Examples
--------
>>> c = pd.Categorical(['a', 'b'])
>>> c
[a, b]
Categories (2, object): [a, b]

>>> c._set_categories(pd.Index(['a', 'c']))
>>> c
[a, c]
Categories (2, object): [a, c]
def _set_categories(self, categories, fastpath=False):
    " Sets new categories inplace\n\n        Parameters\n        ----------\n        fastpath : boolean (default: False)\n           Don't perform validation of the categories for uniqueness or nulls\n\n        Examples\n        --------\n        >>> c = pd.Categorical(['a', 'b'])\n        >>> c\n        [a, b]\n        Categories (2, object): [a, b]\n\n        >>> c._set_categories(pd.Index(['a', 'c']))\n        >>> c\n        [a, c]\n        Categories (2, object): [a, c]\n        "
    if fastpath:
        new_dtype = CategoricalDtype._from_fastpath(categories, self.ordered)
    else:
        new_dtype = CategoricalDtype(categories, ordered=self.ordered)
    if ((not fastpath) and (self.dtype.categories is not None) and (len(new_dtype.categories) != len(self.dtype.categories))):
        raise ValueError('new categories need to have the same number of items than the old categories!')
    self._dtype = new_dtype