@@ -611,8 +611,9 @@ def __init__(
611
611
if _left .columns .nlevels != _right .columns .nlevels :
612
612
msg = (
613
613
"merging between different levels can give an unintended "
614
- "result ({left} levels on the left, {right} on the right)"
615
- ).format (left = _left .columns .nlevels , right = _right .columns .nlevels )
614
+ f"result ({ left .columns .nlevels } levels on the left,"
615
+ f"{ right .columns .nlevels } on the right)"
616
+ )
616
617
warnings .warn (msg , UserWarning )
617
618
618
619
self ._validate_specification ()
@@ -679,7 +680,7 @@ def _indicator_pre_merge(
679
680
if i in columns :
680
681
raise ValueError (
681
682
"Cannot use `indicator=True` option when "
682
- "data contains a column named {name}" . format ( name = i )
683
+ f "data contains a column named { i } "
683
684
)
684
685
if self .indicator_name in columns :
685
686
raise ValueError (
@@ -831,7 +832,7 @@ def _maybe_add_join_keys(self, result, left_indexer, right_indexer):
831
832
else :
832
833
result .index = Index (key_col , name = name )
833
834
else :
834
- result .insert (i , name or "key_{i}" . format ( i = i ) , key_col )
835
+ result .insert (i , name or f "key_{ i } " , key_col )
835
836
836
837
def _get_join_indexers (self ):
837
838
""" return the join indexers """
@@ -1185,13 +1186,10 @@ def _validate_specification(self):
1185
1186
if len (common_cols ) == 0 :
1186
1187
raise MergeError (
1187
1188
"No common columns to perform merge on. "
1188
- "Merge options: left_on={lon}, right_on={ron}, "
1189
- "left_index={lidx}, right_index={ridx}" .format (
1190
- lon = self .left_on ,
1191
- ron = self .right_on ,
1192
- lidx = self .left_index ,
1193
- ridx = self .right_index ,
1194
- )
1189
+ f"Merge options: left_on={ self .left_on } , "
1190
+ f"right_on={ self .right_on } , "
1191
+ f"left_index={ self .left_index } , "
1192
+ f"right_index={ self .right_index } "
1195
1193
)
1196
1194
if not common_cols .is_unique :
1197
1195
raise MergeError (f"Data columns not unique: { repr (common_cols )} " )
@@ -1486,12 +1484,12 @@ def get_result(self):
1486
1484
1487
1485
1488
1486
def _asof_function (direction : str ):
1489
- name = "asof_join_{dir}" . format ( dir = direction )
1487
+ name = f "asof_join_{ direction } "
1490
1488
return getattr (libjoin , name , None )
1491
1489
1492
1490
1493
1491
def _asof_by_function (direction : str ):
1494
- name = "asof_join_{dir }_on_X_by_Y" . format ( dir = direction )
1492
+ name = f "asof_join_{ direction } _on_X_by_Y"
1495
1493
return getattr (libjoin , name , None )
1496
1494
1497
1495
@@ -1601,9 +1599,7 @@ def _validate_specification(self):
1601
1599
1602
1600
# check 'direction' is valid
1603
1601
if self .direction not in ["backward" , "forward" , "nearest" ]:
1604
- raise MergeError (
1605
- "direction invalid: {direction}" .format (direction = self .direction )
1606
- )
1602
+ raise MergeError (f"direction invalid: { self .direction } " )
1607
1603
1608
1604
@property
1609
1605
def _asof_key (self ):
@@ -1628,17 +1624,13 @@ def _get_merge_keys(self):
1628
1624
# later with a ValueError, so we don't *need* to check
1629
1625
# for them here.
1630
1626
msg = (
1631
- "incompatible merge keys [{i}] {lkdtype} and "
1632
- "{rkdtype}, both sides category, but not equal ones" .format (
1633
- i = i , lkdtype = repr (lk .dtype ), rkdtype = repr (rk .dtype )
1634
- )
1627
+ f"incompatible merge keys [{ i } ] { repr (lk .dtype )} and "
1628
+ f"{ repr (rk .dtype )} , both sides category, but not equal ones"
1635
1629
)
1636
1630
else :
1637
1631
msg = (
1638
- "incompatible merge keys [{i}] {lkdtype} and "
1639
- "{rkdtype}, must be the same type" .format (
1640
- i = i , lkdtype = repr (lk .dtype ), rkdtype = repr (rk .dtype )
1641
- )
1632
+ f"incompatible merge keys [{ i } ] { repr (lk .dtype )} and "
1633
+ f"{ repr (rk .dtype )} , must be the same type"
1642
1634
)
1643
1635
raise MergeError (msg )
1644
1636
@@ -1651,10 +1643,8 @@ def _get_merge_keys(self):
1651
1643
lt = left_join_keys [- 1 ]
1652
1644
1653
1645
msg = (
1654
- "incompatible tolerance {tolerance}, must be compat "
1655
- "with type {lkdtype}" .format (
1656
- tolerance = type (self .tolerance ), lkdtype = repr (lt .dtype )
1657
- )
1646
+ f"incompatible tolerance { self .tolerance } , must be compat "
1647
+ f"with type { repr (lk .dtype )} "
1658
1648
)
1659
1649
1660
1650
if needs_i8_conversion (lt ):
@@ -1680,8 +1670,11 @@ def _get_merge_keys(self):
1680
1670
1681
1671
# validate allow_exact_matches
1682
1672
if not is_bool (self .allow_exact_matches ):
1683
- msg = "allow_exact_matches must be boolean, passed {passed}"
1684
- raise MergeError (msg .format (passed = self .allow_exact_matches ))
1673
+ msg = (
1674
+ "allow_exact_matches must be boolean, "
1675
+ f"passed { self .allow_exact_matches } "
1676
+ )
1677
+ raise MergeError (msg )
1685
1678
1686
1679
return left_join_keys , right_join_keys , join_names
1687
1680
0 commit comments