@@ -302,7 +302,7 @@ def _get_op_name(op, special):
302
302
"""
303
303
opname = op .__name__ .strip ("_" )
304
304
if special :
305
- opname = "__{opname}__" . format ( opname = opname )
305
+ opname = f "__{ opname } __"
306
306
return opname
307
307
308
308
@@ -385,7 +385,7 @@ def column_op(a, b):
385
385
return {i : func (a .iloc [:, i ], b .iloc [:, i ]) for i in range (len (a .columns ))}
386
386
387
387
elif isinstance (right , ABCSeries ) and axis == "columns" :
388
- # We only get here if called via _combine_frame_series ,
388
+ # We only get here if called via _combine_series_frame ,
389
389
# in which case we specifically want to operate row-by-row
390
390
assert right .index .equals (left .columns )
391
391
@@ -603,9 +603,7 @@ def _combine_series_frame(self, other, func, fill_value=None, axis=None, level=N
603
603
result : DataFrame
604
604
"""
605
605
if fill_value is not None :
606
- raise NotImplementedError (
607
- "fill_value {fill} not supported." .format (fill = fill_value )
608
- )
606
+ raise NotImplementedError (f"fill_value { fill_value } not supported." )
609
607
610
608
if axis is None :
611
609
# default axis is columns
@@ -661,15 +659,13 @@ def to_series(right):
661
659
else :
662
660
raise ValueError (
663
661
"Unable to coerce to DataFrame, shape "
664
- "must be {req_shape}: given {given_shape}" .format (
665
- req_shape = left .shape , given_shape = right .shape
666
- )
662
+ f"must be { left .shape } : given { right .shape } "
667
663
)
668
664
669
665
elif right .ndim > 2 :
670
666
raise ValueError (
671
667
"Unable to coerce to Series/DataFrame, dim "
672
- "must be <= 2: {dim}" . format ( dim = right .shape )
668
+ f "must be <= 2: { right .shape } "
673
669
)
674
670
675
671
elif is_list_like (right ) and not isinstance (right , (ABCSeries , ABCDataFrame )):
@@ -702,7 +698,11 @@ def f(self, other, axis=default_axis, level=None, fill_value=None):
702
698
# Another DataFrame
703
699
pass_op = op if should_series_dispatch (self , other , op ) else na_op
704
700
pass_op = pass_op if not is_logical else op
705
- return self ._combine_frame (other , pass_op , fill_value , level )
701
+
702
+ left , right = self .align (other , join = "outer" , level = level , copy = False )
703
+ new_data = left ._combine_frame (right , pass_op , fill_value )
704
+ return left ._construct_result (new_data )
705
+
706
706
elif isinstance (other , ABCSeries ):
707
707
# For these values of `axis`, we end up dispatching to Series op,
708
708
# so do not want the masked op.
@@ -763,7 +763,7 @@ def _comp_method_FRAME(cls, op, special):
763
763
str_rep = _get_opstr (op )
764
764
op_name = _get_op_name (op , special )
765
765
766
- @Appender ("Wrapper for comparison method {name}" . format ( name = op_name ) )
766
+ @Appender (f "Wrapper for comparison method { op_name } " )
767
767
def f (self , other ):
768
768
769
769
other = _align_method_FRAME (self , other , axis = None )
0 commit comments