#NEWLINE# def __getitem__( self , key ) : #NEWLINE# #INDENT# ' Return an item. ' #NEWLINE# if isinstance ( key , ( int , np . integer ) ) : #NEWLINE# #INDENT# i = key . _codes [ key ] #NEWLINE# if ( i == ( - 1 ) ) : #NEWLINE# #INDENT# return np . nan #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . categories [ i ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# return Categorical ( values = self . _codes [ key ] , categories = self . categories , ordered = self . ordered , fastpath = True )