@@ -395,16 +395,12 @@ def isin(comps, values) -> np.ndarray:
395
395
if not is_list_like (comps ):
396
396
raise TypeError (
397
397
"only list-like objects are allowed to be passed"
398
- " to isin(), you passed a [{comps_type}]" .format (
399
- comps_type = type (comps ).__name__
400
- )
398
+ f" to isin(), you passed a [{ type (comps ).__name__ } ]"
401
399
)
402
400
if not is_list_like (values ):
403
401
raise TypeError (
404
402
"only list-like objects are allowed to be passed"
405
- " to isin(), you passed a [{values_type}]" .format (
406
- values_type = type (values ).__name__
407
- )
403
+ f" to isin(), you passed a [{ type (values ).__name__ } ]"
408
404
)
409
405
410
406
if not isinstance (values , (ABCIndex , ABCSeries , np .ndarray )):
@@ -601,7 +597,7 @@ def _factorize_array(
601
597
)
602
598
@Appender (_shared_docs ["factorize" ])
603
599
def factorize (
604
- values , sort : bool = False , na_sentinel : int = - 1 , size_hint : Optional [int ] = None ,
600
+ values , sort : bool = False , na_sentinel : int = - 1 , size_hint : Optional [int ] = None
605
601
) -> Tuple [np .ndarray , Union [np .ndarray , ABCIndex ]]:
606
602
# Implementation notes: This method is responsible for 3 things
607
603
# 1.) coercing data to array-like (ndarray, Index, extension array)
@@ -758,7 +754,7 @@ def _value_counts_arraylike(values, dropna: bool):
758
754
# ndarray like
759
755
760
756
# TODO: handle uint8
761
- f = getattr (htable , "value_count_{dtype}" . format ( dtype = ndtype ) )
757
+ f = getattr (htable , f "value_count_{ ndtype } " )
762
758
keys , counts = f (values , dropna )
763
759
764
760
mask = isna (values )
@@ -794,7 +790,7 @@ def duplicated(values, keep="first") -> np.ndarray:
794
790
795
791
values , _ = _ensure_data (values )
796
792
ndtype = values .dtype .name
797
- f = getattr (htable , "duplicated_{dtype}" . format ( dtype = ndtype ) )
793
+ f = getattr (htable , f "duplicated_{ ndtype } " )
798
794
return f (values , keep = keep )
799
795
800
796
@@ -833,12 +829,12 @@ def mode(values, dropna: bool = True) -> ABCSeries:
833
829
values , _ = _ensure_data (values )
834
830
ndtype = values .dtype .name
835
831
836
- f = getattr (htable , "mode_{dtype}" . format ( dtype = ndtype ) )
832
+ f = getattr (htable , f "mode_{ ndtype } " )
837
833
result = f (values , dropna = dropna )
838
834
try :
839
835
result = np .sort (result )
840
836
except TypeError as e :
841
- warn ("Unable to sort modes: {error}" . format ( error = e ) )
837
+ warn (f "Unable to sort modes: { e } " )
842
838
843
839
result = _reconstruct_data (result , original .dtype , original )
844
840
return Series (result )
@@ -1110,10 +1106,7 @@ def compute(self, method):
1110
1106
n = self .n
1111
1107
dtype = self .obj .dtype
1112
1108
if not self .is_valid_dtype_n_method (dtype ):
1113
- raise TypeError (
1114
- "Cannot use method '{method}' with "
1115
- "dtype {dtype}" .format (method = method , dtype = dtype )
1116
- )
1109
+ raise TypeError (f"Cannot use method '{ method } ' with dtype { dtype } " )
1117
1110
1118
1111
if n <= 0 :
1119
1112
return self .obj [[]]
0 commit comments