From 05e7118dd8fe2f82ec0eb8c376a5ad91628f32bd Mon Sep 17 00:00:00 2001 From: HH-MWB Date: Sat, 11 Jan 2020 08:48:11 -0500 Subject: [PATCH 1/4] replace syntax with f-string --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 5ad133f9e21a4..676b78573399c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2431,7 +2431,7 @@ def _verbose_repr(): dtype = self.dtypes.iloc[i] col = pprint_thing(col) - line_no = _put_str(" {num}".format(num=i), space_num) + line_no = _put_str(f" {i}", space_num) count = "" if show_counts: count = counts.iloc[i] From 10ea6a5b5b824f3633dbf08eb766cdc1f165a1ef Mon Sep 17 00:00:00 2001 From: HH-MWB Date: Sat, 11 Jan 2020 09:18:14 -0500 Subject: [PATCH 2/4] replace syntax with f-string --- pandas/core/arrays/period.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 8b49c2186dde0..697d759206ff9 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -298,11 +298,11 @@ def __arrow_array__(self, type=None): if self.freqstr != type.freq: raise TypeError( "Not supported to convert PeriodArray to array with different" - " 'freq' ({0} vs {1})".format(self.freqstr, type.freq) + f" 'freq' ({self.freqstr} vs {type.freq})" ) else: raise TypeError( - "Not supported to convert PeriodArray to '{0}' type".format(type) + f"Not supported to convert PeriodArray to '{type}' type" ) period_type = ArrowPeriodType(self.freqstr) From 8acdc6421bbc647056bd1cbabffb940e7085d96c Mon Sep 17 00:00:00 2001 From: HH-MWB Date: Sat, 11 Jan 2020 09:23:53 -0500 Subject: [PATCH 3/4] replace syntax with f-string --- pandas/core/dtypes/common.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 5a007f28d63cb..f62f03be9b732 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -194,12 +194,11 @@ def ensure_python_int(value: Union[int, np.integer]) -> int: """ if not is_scalar(value): raise TypeError(f"Value needs to be a scalar value, was type {type(value)}") - msg = "Wrong type {} for value {}" try: new_value = int(value) assert new_value == value except (TypeError, ValueError, AssertionError): - raise TypeError(msg.format(type(value), value)) + raise TypeError(f"Wrong type {type(value)} for value {value}") return new_value From 9083bdc6fc7601199c1651b4c3353dcfbc3ec89e Mon Sep 17 00:00:00 2001 From: HH-MWB Date: Sat, 11 Jan 2020 09:25:39 -0500 Subject: [PATCH 4/4] replace syntax with f-string --- pandas/core/dtypes/dtypes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 466ed815e8e5a..93522abc3a48f 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -435,12 +435,11 @@ def __eq__(self, other: Any) -> bool: return hash(self) == hash(other) def __repr__(self) -> str_type: - tpl = "CategoricalDtype(categories={data}ordered={ordered})" if self.categories is None: data = "None, " else: data = self.categories._format_data(name=type(self).__name__) - return tpl.format(data=data, ordered=self.ordered) + return f"CategoricalDtype(categories={data}ordered={self.ordered})" @staticmethod def _hash_categories(categories, ordered: Ordered = True) -> int: