#NEWLINE# def test_crosstab_with_empties( self ) : #NEWLINE# #INDENT# df = pd . DataFrame ( { #NEWLINE# #INDENT# 'a' : [ 1 , 2 , 2 , 2 , 2 ] , #NEWLINE# 'b' : [ 3 , 3 , 4 , 4 , 4 ] , #NEWLINE# 'c' : [ np . nan , np . nan , np . nan , np . nan , np . nan ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# empty = pd . DataFrame ( [ [ 0.0 , 0.0 ] , [ 0.0 , 0.0 ] ] , index = pd . Index ( [ 1 , 2 ] , name = 'a' , dtype = 'int64' ) , columns = pd . Index ( [ 3 , 4 ] , name = 'b' ) ) #NEWLINE# for i in [ True , 'index' , 'columns' ] : #NEWLINE# #INDENT# calculated = pd . crosstab ( df . a , df . b , values = df . c , aggfunc = 'count' , normalize = i ) #NEWLINE# tm . assert_frame_equal ( empty , calculated ) #NEWLINE# #UNINDENT# nans = pd . DataFrame ( [ [ 0.0 , np . nan ] , [ 0.0 , 0.0 ] ] , index = pd . Index ( [ 1 , 2 ] , name = 'a' , dtype = 'int64' ) , columns = pd . Index ( [ 3 , 4 ] , name = 'b' ) ) #NEWLINE# calculated = pd . crosstab ( df . a , df . b , values = df . c , aggfunc = 'count' , normalize = False ) #NEWLINE# tm . assert_frame_equal ( nans , calculated )