@@ -534,28 +534,27 @@ def __init__(self, left, right, how='inner', on=None,
534534 'indicator option can only accept boolean or string arguments' )
535535
536536 if not isinstance (left , DataFrame ):
537- raise ValueError (
538- 'can not merge DataFrame with instance of '
539- 'type {0}' .format (type (left )))
537+ raise ValueError ('can not merge DataFrame with instance of '
538+ 'type {left}' .format (left = type (left )))
540539 if not isinstance (right , DataFrame ):
541- raise ValueError (
542- 'can not merge DataFrame with instance of '
543- 'type {0}' .format (type (right )))
540+ raise ValueError ('can not merge DataFrame with instance of '
541+ 'type {right}' .format (right = type (right )))
544542
545543 if not is_bool (left_index ):
546544 raise ValueError (
547545 'left_index parameter must be of type bool, not '
548- '{0 }' .format (type (left_index )))
546+ '{left_index }' .format (left_index = type (left_index )))
549547 if not is_bool (right_index ):
550548 raise ValueError (
551549 'right_index parameter must be of type bool, not '
552- '{0 }' .format (type (right_index )))
550+ '{right_index }' .format (right_index = type (right_index )))
553551
554552 # warn user when merging between different levels
555553 if left .columns .nlevels != right .columns .nlevels :
556554 msg = ('merging between different levels can give an unintended '
557- 'result ({0} levels on the left, {1} on the right)' )
558- msg = msg .format (left .columns .nlevels , right .columns .nlevels )
555+ 'result ({left} levels on the left, {right} on the right)'
556+ ).format (left = left .columns .nlevels ,
557+ right = right .columns .nlevels )
559558 warnings .warn (msg , UserWarning )
560559
561560 self ._validate_specification ()
@@ -613,7 +612,8 @@ def _indicator_pre_merge(self, left, right):
613612 for i in ['_left_indicator' , '_right_indicator' ]:
614613 if i in columns :
615614 raise ValueError ("Cannot use `indicator=True` option when "
616- "data contains a column named {}" .format (i ))
615+ "data contains a column named {name}"
616+ .format (name = i ))
617617 if self .indicator_name in columns :
618618 raise ValueError (
619619 "Cannot use name of an existing column for indicator column" )
@@ -717,7 +717,7 @@ def _maybe_add_join_keys(self, result, left_indexer, right_indexer):
717717 if name in result :
718718 result [name ] = key_col
719719 else :
720- result .insert (i , name or 'key_%d' % i , key_col )
720+ result .insert (i , name or 'key_{i}' . format ( i = i ) , key_col )
721721
722722 def _get_join_indexers (self ):
723723 """ return the join indexers """
@@ -952,8 +952,8 @@ def _validate_specification(self):
952952 if len (common_cols ) == 0 :
953953 raise MergeError ('No common columns to perform merge on' )
954954 if not common_cols .is_unique :
955- raise MergeError ("Data columns not unique: %s "
956- % repr ( common_cols ))
955+ raise MergeError ("Data columns not unique: {common!r} "
956+ . format ( common = common_cols ))
957957 self .left_on = self .right_on = common_cols
958958 elif self .on is not None :
959959 if self .left_on is not None or self .right_on is not None :
@@ -1119,12 +1119,14 @@ def get_result(self):
11191119
11201120
11211121def _asof_function (direction , on_type ):
1122- return getattr (libjoin , 'asof_join_%s_%s' % (direction , on_type ), None )
1122+ name = 'asof_join_{dir}_{on}' .format (dir = direction , on = on_type )
1123+ return getattr (libjoin , name , None )
11231124
11241125
11251126def _asof_by_function (direction , on_type , by_type ):
1126- return getattr (libjoin , 'asof_join_%s_%s_by_%s' %
1127- (direction , on_type , by_type ), None )
1127+ name = 'asof_join_{dir}_{on}_by_{by}' .format (
1128+ dir = direction , on = on_type , by = by_type )
1129+ return getattr (libjoin , name , None )
11281130
11291131
11301132_type_casters = {
@@ -1153,7 +1155,7 @@ def _get_cython_type(dtype):
11531155 type_name = _get_dtype (dtype ).name
11541156 ctype = _cython_types .get (type_name , 'object' )
11551157 if ctype == 'error' :
1156- raise MergeError ('unsupported type: ' + type_name )
1158+ raise MergeError ('unsupported type: {type}' . format ( type = type_name ) )
11571159 return ctype
11581160
11591161
@@ -1235,7 +1237,8 @@ def _validate_specification(self):
12351237
12361238 # check 'direction' is valid
12371239 if self .direction not in ['backward' , 'forward' , 'nearest' ]:
1238- raise MergeError ('direction invalid: ' + self .direction )
1240+ raise MergeError ('direction invalid: {direction}'
1241+ .format (direction = self .direction ))
12391242
12401243 @property
12411244 def _asof_key (self ):
@@ -1264,7 +1267,7 @@ def _get_merge_keys(self):
12641267 lt = left_join_keys [- 1 ]
12651268
12661269 msg = "incompatible tolerance, must be compat " \
1267- "with type {0 }" .format (type (lt ))
1270+ "with type {lt }" .format (lt = type (lt ))
12681271
12691272 if is_datetime64_dtype (lt ) or is_datetime64tz_dtype (lt ):
12701273 if not isinstance (self .tolerance , Timedelta ):
@@ -1283,8 +1286,8 @@ def _get_merge_keys(self):
12831286
12841287 # validate allow_exact_matches
12851288 if not is_bool (self .allow_exact_matches ):
1286- raise MergeError ( "allow_exact_matches must be boolean, "
1287- "passed {0}" .format (self .allow_exact_matches ))
1289+ msg = "allow_exact_matches must be boolean, passed {passed} "
1290+ raise MergeError ( msg .format (passed = self .allow_exact_matches ))
12881291
12891292 return left_join_keys , right_join_keys , join_names
12901293
@@ -1306,11 +1309,11 @@ def flip(xs):
13061309 tolerance = self .tolerance
13071310
13081311 # we required sortedness in the join keys
1309- msg = " keys must be sorted"
1312+ msg = "{side} keys must be sorted"
13101313 if not Index (left_values ).is_monotonic :
1311- raise ValueError ('left' + msg )
1314+ raise ValueError (msg . format ( side = 'left' ) )
13121315 if not Index (right_values ).is_monotonic :
1313- raise ValueError ('right' + msg )
1316+ raise ValueError (msg . format ( side = 'right' ) )
13141317
13151318 # initial type conversion as needed
13161319 if needs_i8_conversion (left_values ):
0 commit comments