@@ -4818,13 +4818,14 @@ def _arith_op(left, right):
4818
4818
return ops .dispatch_to_series (this , other , _arith_op )
4819
4819
else :
4820
4820
result = _arith_op (this .values , other .values )
4821
-
4822
- return self . _constructor ( result , index = new_index , columns = new_columns ,
4823
- copy = False )
4821
+ return self . _constructor ( result ,
4822
+ index = new_index , columns = new_columns ,
4823
+ copy = False )
4824
4824
4825
4825
def _combine_match_index (self , other , func , level = None ):
4826
4826
left , right = self .align (other , join = 'outer' , axis = 0 , level = level ,
4827
4827
copy = False )
4828
+ assert left .index .equals (right .index )
4828
4829
new_data = func (left .values .T , right .values ).T
4829
4830
return self ._constructor (new_data ,
4830
4831
index = left .index , columns = self .columns ,
@@ -4833,6 +4834,7 @@ def _combine_match_index(self, other, func, level=None):
4833
4834
def _combine_match_columns (self , other , func , level = None , try_cast = True ):
4834
4835
left , right = self .align (other , join = 'outer' , axis = 1 , level = level ,
4835
4836
copy = False )
4837
+ assert left .columns .equals (right .index )
4836
4838
4837
4839
new_data = left ._data .eval (func = func , other = right ,
4838
4840
axes = [left .columns , self .index ],
@@ -4841,12 +4843,7 @@ def _combine_match_columns(self, other, func, level=None, try_cast=True):
4841
4843
4842
4844
def _combine_const (self , other , func , errors = 'raise' , try_cast = True ):
4843
4845
if lib .is_scalar (other ) or np .ndim (other ) == 0 :
4844
- new_data = {i : func (self .iloc [:, i ], other )
4845
- for i , col in enumerate (self .columns )}
4846
-
4847
- result = self ._constructor (new_data , index = self .index , copy = False )
4848
- result .columns = self .columns
4849
- return result
4846
+ return ops .dispatch_to_series (self , other , func )
4850
4847
4851
4848
new_data = self ._data .eval (func = func , other = other ,
4852
4849
errors = errors ,
0 commit comments