@@ -421,8 +421,7 @@ def _construct_axes_from_arguments(
421
421
if a in kwargs :
422
422
if alias in kwargs :
423
423
raise TypeError (
424
- "arguments are mutually exclusive "
425
- "for [%s,%s]" % (a , alias )
424
+ f"arguments are mutually exclusive for [{ a } ,{ alias } ]"
426
425
)
427
426
continue
428
427
if alias in kwargs :
@@ -754,7 +753,7 @@ def transpose(self, *args, **kwargs):
754
753
755
754
# we must have unique axes
756
755
if len (axes ) != len (set (axes )):
757
- raise ValueError ("Must specify %s unique axes" % self . _AXIS_LEN )
756
+ raise ValueError (f "Must specify { self . _AXIS_LEN } unique axes" )
758
757
759
758
new_axes = self ._construct_axes_dict_from (
760
759
self , [self ._get_axis (x ) for x in axes_names ]
@@ -2096,7 +2095,7 @@ def __repr__(self) -> str:
2096
2095
# string representation based upon iterating over self
2097
2096
# (since, by definition, `PandasContainers` are iterable)
2098
2097
prepr = "[%s]" % "," .join (map (pprint_thing , self ))
2099
- return "%s(%s)" % ( self .__class__ .__name__ , prepr )
2098
+ return f" { self .__class__ .__name__ } ( { prepr } )"
2100
2099
2101
2100
def _repr_latex_ (self ):
2102
2101
"""
@@ -6357,7 +6356,7 @@ def fillna(
6357
6356
elif isinstance (value , ABCDataFrame ) and self .ndim == 2 :
6358
6357
new_data = self .where (self .notna (), value )
6359
6358
else :
6360
- raise ValueError ("invalid fill value with a %s" % type (value ))
6359
+ raise ValueError (f "invalid fill value with a { type (value )} " )
6361
6360
6362
6361
if inplace :
6363
6362
self ._update_inplace (new_data )
@@ -6794,9 +6793,8 @@ def replace(
6794
6793
if is_list_like (value ):
6795
6794
if len (to_replace ) != len (value ):
6796
6795
raise ValueError (
6797
- "Replacement lists must match "
6798
- "in length. Expecting %d got %d "
6799
- % (len (to_replace ), len (value ))
6796
+ f"Replacement lists must match in length. "
6797
+ f"Expecting { len (to_replace )} got { len (value )} "
6800
6798
)
6801
6799
6802
6800
new_data = self ._data .replace_list (
@@ -8871,7 +8869,7 @@ def align(
8871
8869
fill_axis = fill_axis ,
8872
8870
)
8873
8871
else : # pragma: no cover
8874
- raise TypeError ("unsupported type: %s" % type (other ))
8872
+ raise TypeError (f "unsupported type: { type (other )} " )
8875
8873
8876
8874
def _align_frame (
8877
8875
self ,
@@ -9515,9 +9513,9 @@ def tshift(self, periods=1, freq=None, axis=0):
9515
9513
new_data = self ._data .copy ()
9516
9514
new_data .axes [block_axis ] = index .shift (periods )
9517
9515
else :
9518
- msg = "Given freq %s does not match PeriodIndex freq %s" % (
9519
- freq .rule_code ,
9520
- orig_freq .rule_code ,
9516
+ msg = (
9517
+ f"Given freq { freq .rule_code } does not match"
9518
+ f" PeriodIndex freq { orig_freq .rule_code } "
9521
9519
)
9522
9520
raise ValueError (msg )
9523
9521
else :
@@ -9665,7 +9663,7 @@ def truncate(self, before=None, after=None, axis=None, copy=True):
9665
9663
9666
9664
if before is not None and after is not None :
9667
9665
if before > after :
9668
- raise ValueError ("Truncate: %s must be after %s" % ( after , before ) )
9666
+ raise ValueError (f "Truncate: { after } must be after { before } " )
9669
9667
9670
9668
slicer = [slice (None , None )] * self ._AXIS_LEN
9671
9669
slicer [axis ] = slice (before , after )
@@ -9711,7 +9709,7 @@ def _tz_convert(ax, tz):
9711
9709
if len (ax ) > 0 :
9712
9710
ax_name = self ._get_axis_name (axis )
9713
9711
raise TypeError (
9714
- "%s is not a valid DatetimeIndex or PeriodIndex" % ax_name
9712
+ f" { ax_name } is not a valid DatetimeIndex or PeriodIndex"
9715
9713
)
9716
9714
else :
9717
9715
ax = DatetimeIndex ([], tz = tz )
@@ -9875,7 +9873,7 @@ def _tz_localize(ax, tz, ambiguous, nonexistent):
9875
9873
if len (ax ) > 0 :
9876
9874
ax_name = self ._get_axis_name (axis )
9877
9875
raise TypeError (
9878
- "%s is not a valid DatetimeIndex or PeriodIndex" % ax_name
9876
+ f" { ax_name } is not a valid DatetimeIndex or PeriodIndex"
9879
9877
)
9880
9878
else :
9881
9879
ax = DatetimeIndex ([], tz = tz )
0 commit comments