Skip to content

Commit 4ed5e54

Browse files
committed
CLN: Update pivot.py with fstrings (pandas-dev#29527)
All changes made for pivot.py + black pandas formatting.
1 parent e6115fc commit 4ed5e54

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pandas/core/reshape/pivot.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _add_margins(
193193
if not isinstance(margins_name, str):
194194
raise ValueError("margins_name argument must be a string")
195195

196-
msg = 'Conflicting name "{name}" in margins'.format(name=margins_name)
196+
msg = f'Conflicting name "{margins_name}" in margins'
197197
for level in table.index.names:
198198
if margins_name in table.index.get_level_values(level):
199199
raise ValueError(msg)
@@ -620,9 +620,7 @@ def _normalize(table, normalize, margins, margins_name="All"):
620620
if (margins_name not in table.iloc[-1, :].name) | (
621621
margins_name != table.iloc[:, -1].name
622622
):
623-
raise ValueError(
624-
"{mname} not in pivoted DataFrame".format(mname=margins_name)
625-
)
623+
raise ValueError(f"{margins_name} not in pivoted DataFrame")
626624
column_margin = table.iloc[:-1, -1]
627625
index_margin = table.iloc[-1, :-1]
628626

@@ -672,7 +670,7 @@ def _get_names(arrs, names, prefix="row"):
672670
if isinstance(arr, ABCSeries) and arr.name is not None:
673671
names.append(arr.name)
674672
else:
675-
names.append("{prefix}_{i}".format(prefix=prefix, i=i))
673+
names.append(f"{prefix}_{i}")
676674
else:
677675
if len(names) != len(arrs):
678676
raise AssertionError("arrays and names must have the same length")

0 commit comments

Comments
 (0)