#NEWLINE# def remove_categories( self , removals , inplace = False ) : #NEWLINE# #INDENT# ' Removes the specified categories.\n\n        `removals` must be included in the old categories. Values which were in\n        the removed categories will be set to NaN\n\n        Raises\n        ------\n        ValueError\n            If the removals are not contained in the categories\n\n        Parameters\n        ----------\n        removals : category or list of categories\n           The categories which should be removed.\n        inplace : boolean (default: False)\n           Whether or not to remove the categories inplace or return a copy of\n           this categorical with removed categories.\n\n        Returns\n        -------\n        cat : Categorical with removed categories or None if inplace.\n\n        See also\n        --------\n        rename_categories\n        reorder_categories\n        add_categories\n        remove_unused_categories\n        set_categories\n        ' #NEWLINE# if ( not is_list_like ( removals ) ) : #NEWLINE# #INDENT# removals = [ removals ] #NEWLINE# #UNINDENT# removal_set = set ( list ( removals ) ) #NEWLINE# not_included = ( removal_set - set ( self . _categories ) ) #NEWLINE# new_categories = [ c for c in self . _categories if ( c not in removal_set ) ] #NEWLINE# if any ( isnull ( removals ) ) : #NEWLINE# #INDENT# not_included = [ x for x in not_included if notnull ( x ) ] #NEWLINE# new_categories = [ x for x in new_categories if notnull ( x ) ] #NEWLINE# #UNINDENT# if ( len ( not_included ) != 0 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'removals must all be in old categories: %s' % str ( not_included ) ) ) #NEWLINE# #UNINDENT# return self . set_categories ( new_categories , ordered = self . ordered , rename = False , inplace = inplace )