#NEWLINE# def test_apply_categorical( self ) : #NEWLINE# #INDENT# values = pd . Categorical ( list ( 'ABBABCD' ) , categories = list ( 'DCBA' ) , ordered = True ) #NEWLINE# s = pd . Series ( values , name = 'XX' , index = list ( 'abcdefg' ) ) #NEWLINE# result = s . apply ( ( lambda x : x . lower ( ) ) ) #NEWLINE# values = pd . Categorical ( list ( 'abbabcd' ) , categories = list ( 'dcba' ) , ordered = True ) #NEWLINE# exp = pd . Series ( values , name = 'XX' , index = list ( 'abcdefg' ) ) #NEWLINE# tm . assert_series_equal ( result , exp ) #NEWLINE# tm . assert_categorical_equal ( result . values , exp . values ) #NEWLINE# result = s . apply ( ( lambda x : 'A' ) ) #NEWLINE# exp = pd . Series ( ( [ 'A' ] * 7 ) , name = 'XX' , index = list ( 'abcdefg' ) ) #NEWLINE# tm . assert_series_equal ( result , exp ) #NEWLINE# self . assertEqual ( result . dtype , np . object )