#NEWLINE# def test_diff( self ) : #NEWLINE# #INDENT# the_diff = self . tsframe . diff ( 1 ) #NEWLINE# assert_series_equal ( result [ 'A' ] , ( self . tsframe [ 'A' ] - self . tsframe [ 'A' ] . shift ( 1 ) ) ) #NEWLINE# a = 10000000000000000 #NEWLINE# b = ( a + 1 ) #NEWLINE# s = Series ( [ a , b ] ) #NEWLINE# rs = DataFrame ( { #NEWLINE# #INDENT# 's' : s , #NEWLINE# #UNINDENT# } ) . diff ( ) #NEWLINE# self . assertEqual ( rs . s [ 1 ] , 1 ) #NEWLINE# tf = self . tsframe . astype ( 'float32' ) #NEWLINE# the_diff = tf . diff ( 1 ) #NEWLINE# assert_series_equal ( the_diff [ 'A' ] , ( tf [ 'A' ] - tf [ 'A' ] . shift ( 1 ) ) ) #NEWLINE# df = pd . DataFrame ( { #NEWLINE# #INDENT# 'y' : pd . Series ( [ 2 ] ) , #NEWLINE# 'z' : pd . Series ( [ 3 ] ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# df . insert ( 0 , 'x' , 1 ) #NEWLINE# result = df . diff ( axis = 1 ) #NEWLINE# expected = pd . DataFrame ( { #NEWLINE# #INDENT# 'x' : np . nan , #NEWLINE# 'y' : pd . Series ( 1 ) , #NEWLINE# 'z' : pd . Series ( 1 ) , #NEWLINE# #UNINDENT# } ) . astype ( 'float64' ) #NEWLINE# assert_frame_equal ( result , expected )