#NEWLINE# def _slice( self , slicer ) : #NEWLINE# #INDENT# ' Return a slice of myself.\n\n        For internal compatibility with numpy arrays.\n        ' #NEWLINE# if ( isinstance ( slicer , tuple ) and ( len ( slicer ) == 2 ) ) : #NEWLINE# #INDENT# if ( not is_null_slice ( slicer [ 0 ] ) ) : #NEWLINE# #INDENT# raise AssertionError ( 'invalid slicing for a 1-ndim categorical' ) #NEWLINE# #UNINDENT# slicer = slicer [ 1 ] #NEWLINE# #UNINDENT# _codes = self . _codes [ slicer ] #NEWLINE# return Categorical ( values = _codes , categories = self . categories , ordered = self . ordered , fastpath = True )