@@ -421,8 +421,7 @@ def _construct_axes_from_arguments(
421421 if a in kwargs :
422422 if alias in kwargs :
423423 raise TypeError (
424- "arguments are mutually exclusive "
425- "for [%s,%s]" % (a , alias )
424+ f"arguments are mutually exclusive for [{ a } ,{ alias } ]"
426425 )
427426 continue
428427 if alias in kwargs :
@@ -754,7 +753,7 @@ def transpose(self, *args, **kwargs):
754753
755754 # we must have unique axes
756755 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" )
758757
759758 new_axes = self ._construct_axes_dict_from (
760759 self , [self ._get_axis (x ) for x in axes_names ]
@@ -2096,7 +2095,7 @@ def __repr__(self) -> str:
20962095 # string representation based upon iterating over self
20972096 # (since, by definition, `PandasContainers` are iterable)
20982097 prepr = "[%s]" % "," .join (map (pprint_thing , self ))
2099- return "%s(%s)" % ( self .__class__ .__name__ , prepr )
2098+ return f" { self .__class__ .__name__ } ( { prepr } )"
21002099
21012100 def _repr_latex_ (self ):
21022101 """
@@ -6357,7 +6356,7 @@ def fillna(
63576356 elif isinstance (value , ABCDataFrame ) and self .ndim == 2 :
63586357 new_data = self .where (self .notna (), value )
63596358 else :
6360- raise ValueError ("invalid fill value with a %s" % type (value ))
6359+ raise ValueError (f "invalid fill value with a { type (value )} " )
63616360
63626361 if inplace :
63636362 self ._update_inplace (new_data )
@@ -6794,9 +6793,8 @@ def replace(
67946793 if is_list_like (value ):
67956794 if len (to_replace ) != len (value ):
67966795 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 )} "
68006798 )
68016799
68026800 new_data = self ._data .replace_list (
@@ -8871,7 +8869,7 @@ def align(
88718869 fill_axis = fill_axis ,
88728870 )
88738871 else : # pragma: no cover
8874- raise TypeError ("unsupported type: %s" % type (other ))
8872+ raise TypeError (f "unsupported type: { type (other )} " )
88758873
88768874 def _align_frame (
88778875 self ,
@@ -9515,9 +9513,9 @@ def tshift(self, periods=1, freq=None, axis=0):
95159513 new_data = self ._data .copy ()
95169514 new_data .axes [block_axis ] = index .shift (periods )
95179515 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 } "
95219519 )
95229520 raise ValueError (msg )
95239521 else :
@@ -9665,7 +9663,7 @@ def truncate(self, before=None, after=None, axis=None, copy=True):
96659663
96669664 if before is not None and after is not None :
96679665 if before > after :
9668- raise ValueError ("Truncate: %s must be after %s" % ( after , before ) )
9666+ raise ValueError (f "Truncate: { after } must be after { before } " )
96699667
96709668 slicer = [slice (None , None )] * self ._AXIS_LEN
96719669 slicer [axis ] = slice (before , after )
@@ -9711,7 +9709,7 @@ def _tz_convert(ax, tz):
97119709 if len (ax ) > 0 :
97129710 ax_name = self ._get_axis_name (axis )
97139711 raise TypeError (
9714- "%s is not a valid DatetimeIndex or PeriodIndex" % ax_name
9712+ f" { ax_name } is not a valid DatetimeIndex or PeriodIndex"
97159713 )
97169714 else :
97179715 ax = DatetimeIndex ([], tz = tz )
@@ -9875,7 +9873,7 @@ def _tz_localize(ax, tz, ambiguous, nonexistent):
98759873 if len (ax ) > 0 :
98769874 ax_name = self ._get_axis_name (axis )
98779875 raise TypeError (
9878- "%s is not a valid DatetimeIndex or PeriodIndex" % ax_name
9876+ f" { ax_name } is not a valid DatetimeIndex or PeriodIndex"
98799877 )
98809878 else :
98819879 ax = DatetimeIndex ([], tz = tz )
0 commit comments