@@ -4832,13 +4832,14 @@ def _arith_op(left, right):
4832
4832
return ops .dispatch_to_series (this , other , _arith_op )
4833
4833
else :
4834
4834
result = _arith_op (this .values , other .values )
4835
-
4836
- return self . _constructor ( result , index = new_index , columns = new_columns ,
4837
- copy = False )
4835
+ return self . _constructor ( result ,
4836
+ index = new_index , columns = new_columns ,
4837
+ copy = False )
4838
4838
4839
4839
def _combine_match_index (self , other , func , level = None ):
4840
4840
left , right = self .align (other , join = 'outer' , axis = 0 , level = level ,
4841
4841
copy = False )
4842
+ assert left .index .equals (right .index )
4842
4843
new_data = func (left .values .T , right .values ).T
4843
4844
return self ._constructor (new_data ,
4844
4845
index = left .index , columns = self .columns ,
@@ -4847,6 +4848,7 @@ def _combine_match_index(self, other, func, level=None):
4847
4848
def _combine_match_columns (self , other , func , level = None , try_cast = True ):
4848
4849
left , right = self .align (other , join = 'outer' , axis = 1 , level = level ,
4849
4850
copy = False )
4851
+ assert left .columns .equals (right .index )
4850
4852
4851
4853
new_data = left ._data .eval (func = func , other = right ,
4852
4854
axes = [left .columns , self .index ],
@@ -4855,12 +4857,7 @@ def _combine_match_columns(self, other, func, level=None, try_cast=True):
4855
4857
4856
4858
def _combine_const (self , other , func , errors = 'raise' , try_cast = True ):
4857
4859
if lib .is_scalar (other ) or np .ndim (other ) == 0 :
4858
- new_data = {i : func (self .iloc [:, i ], other )
4859
- for i , col in enumerate (self .columns )}
4860
-
4861
- result = self ._constructor (new_data , index = self .index , copy = False )
4862
- result .columns = self .columns
4863
- return result
4860
+ return ops .dispatch_to_series (self , other , func )
4864
4861
4865
4862
new_data = self ._data .eval (func = func , other = other ,
4866
4863
errors = errors ,
0 commit comments