@@ -3241,21 +3241,31 @@ def _check_fill(meth, op, a, b, fill_value=0):
32413241 a = Series ([nan , 1. , 2. , 3. , nan ], index = np .arange (5 ))
32423242 b = Series ([nan , 1 , nan , 3 , nan , 4. ], index = np .arange (6 ))
32433243
3244- ops = [Series .add , Series .sub , Series .mul , Series .pow ,
3245- Series .truediv , Series .div ]
3246- equivs = [operator .add , operator .sub , operator .mul , operator .pow ,
3247- operator .truediv ]
3244+ pairings = []
3245+ for op in ['add' , 'sub' , 'mul' , 'pow' , 'truediv' , 'floordiv' ]:
3246+ fv = 0
3247+ lop = getattr (Series , op )
3248+ lequiv = getattr (operator , op )
3249+ rop = getattr (Series , 'r' + op )
3250+ # bind op at definition time...
3251+ requiv = lambda x , y , op = op : getattr (operator , op )(y , x )
3252+ pairings .append ((lop , lequiv , fv ))
3253+ pairings .append ((rop , requiv , fv ))
3254+
32483255 if compat .PY3 :
3249- equivs .append (operator .truediv )
3256+ pairings .append ((Series .div , operator .truediv , 1 ))
3257+ pairings .append ((Series .rdiv , lambda x , y : operator .truediv (y , x ), 1 ))
32503258 else :
3251- equivs .append (operator .div )
3252- fillvals = [ 0 , 0 , 1 , 1 ]
3259+ pairings .append (( Series . div , operator .div , 1 ) )
3260+ pairings . append (( Series . rdiv , lambda x , y : operator . div ( y , x ), 1 ))
32533261
3254- for op , equiv_op , fv in zip ( ops , equivs , fillvals ) :
3262+ for op , equiv_op , fv in pairings :
32553263 result = op (a , b )
32563264 exp = equiv_op (a , b )
32573265 assert_series_equal (result , exp )
32583266 _check_fill (op , equiv_op , a , b , fill_value = fv )
3267+ # should accept axis=0 or axis='rows'
3268+ op (a , b , axis = 0 )
32593269
32603270 def test_combine_first (self ):
32613271 values = tm .makeIntIndex (20 ).values .astype (float )
0 commit comments