@@ -1434,24 +1434,25 @@ def _binop(opname):
1434
1434
# }
1435
1435
# fill_value = fill_values.get(opname)
1436
1436
def opmethod (self , other ):
1437
- pandas_method = getattr (self .data .__class__ , opname )
1438
1437
if isinstance (other , PandasLArray ):
1439
1438
axis , level , (self_al , other_al ) = _pandas_align (self .data ,
1440
1439
other .data ,
1441
1440
join = 'left' )
1442
- res_data = pandas_method (self_al , other_al , axis = axis ,
1443
- level = level )
1441
+ method = getattr (self_al , opname )
1442
+ res_data = method (other_al , axis = axis , level = level )
1443
+ # XXX: sometimes align changes the type of object (DF ->
1444
+ # Series), we might want to convert it back
1444
1445
return self ._wrap_pandas (res_data )
1445
1446
elif isinstance (other , LArray ):
1446
1447
raise NotImplementedError ("mixed LArrays" )
1447
1448
elif isinstance (other , np .ndarray ):
1448
1449
# XXX: not sure how clever Pandas is. We should be able to
1449
1450
# handle extra/missing axes of length 1 (that is why I
1450
1451
# separated the ndarray and scalar cases)
1451
- res_data = pandas_method (self .data , other )
1452
+ res_data = getattr (self .data , opname )( other )
1452
1453
return self ._wrap_pandas (res_data )
1453
1454
elif np .isscalar (other ):
1454
- res_data = pandas_method (self .data , other )
1455
+ res_data = getattr (self .data , opname )( other )
1455
1456
return self ._wrap_pandas (res_data )
1456
1457
else :
1457
1458
raise TypeError ("unsupported operand type(s) for %s: '%s' "
0 commit comments