#NEWLINE# def test_modulo( self ) : #NEWLINE# #INDENT# p = DataFrame ( { #NEWLINE# #INDENT# 'first' : [ 3 , 4 , 5 , 8 ] , #NEWLINE# 'second' : [ 0 , 0 , 0 , 3 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# result = ( p [ 'first' ] % p [ 'second' ] ) #NEWLINE# expected = Series ( ( p [ 'first' ] . values % p [ 'second' ] . values ) , dtype = 'float64' ) #NEWLINE# expected . iloc [ 0 : 3 ] = np . nan #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# result = ( p [ 'first' ] % 0 ) #NEWLINE# expected = Series ( np . nan , index = p . index , name = 'first' ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# p = p . astype ( 'float64' ) #NEWLINE# result = ( p [ 'first' ] % p [ 'second' ] ) #NEWLINE# expected = Series ( ( p [ 'first' ] . values % p [ 'second' ] . values ) ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# p = p . astype ( 'float64' ) #NEWLINE# result = ( p [ 'first' ] % p [ 'second' ] ) #NEWLINE# result2 = ( p [ 'second' ] % p [ 'first' ] ) #NEWLINE# self . assertFalse ( np . array_equal ( result , result2 ) ) #NEWLINE# s = Series ( [ 0 , 1 ] ) #NEWLINE# result = ( s % 0 ) #NEWLINE# expected = Series ( [ nan , nan ] ) #NEWLINE# assert_series_equal ( result , expected ) #NEWLINE# result = ( 0 % s ) #NEWLINE# expected = Series ( [ nan , 0.0 ] ) #NEWLINE# assert_series_equal ( result , expected )