#NEWLINE# def test_crosstab_errors( self ) : #NEWLINE# #INDENT# df = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 , 2 , 2 , 2 ] , #NEWLINE# 'b' : [ 3 , 3 , 4 , 4 , 4 ] , #NEWLINE# 'c' : [ 1 , 1 , np . nan , 1 , 1 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# error = 'values cannot be used without an aggfunc.' #NEWLINE# with tm . assertRaisesRegexp ( ValueError , error ) : #NEWLINE# #INDENT# pd . crosstab ( df . a , df . b , values = df . c ) #NEWLINE# #UNINDENT# error = 'aggfunc cannot be used without values' #NEWLINE# with tm . assertRaisesRegexp ( ValueError , error ) : #NEWLINE# #INDENT# pd . crosstab ( df . a , df . b , aggfunc = np . mean ) #NEWLINE# #UNINDENT# error = 'Not a valid normalize argument' #NEWLINE# with tm . assertRaisesRegexp ( ValueError , error ) : #NEWLINE# #INDENT# pd . crosstab ( df . a , df . b , normalize = '42' ) #NEWLINE# #UNINDENT# with tm . assertRaisesRegexp ( ValueError , error ) : #NEWLINE# #INDENT# pd . crosstab ( df . a , df . b , normalize = 42 ) #NEWLINE# #UNINDENT# error = 'Not a valid margins argument' #NEWLINE# with tm . assertRaisesRegexp ( ValueError , error ) : #NEWLINE# #INDENT# pd . crosstab ( df . a , df . b , normalize = 'all' , margins = 42 )