Skip to content

Commit e6115fc

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

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

pandas/core/reshape/reshape.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -871,15 +871,12 @@ def get_dummies(
871871
# validate prefixes and separator to avoid silently dropping cols
872872
def check_len(item, name):
873873
len_msg = (
874-
"Length of '{name}' ({len_item}) did not match the "
875-
"length of the columns being encoded ({len_enc})."
874+
f"Length of '{name}' ({len(item)}) did not match the "
875+
f"length of the columns being encoded ({data_to_encode.shape[1]})."
876876
)
877877

878878
if is_list_like(item):
879879
if not len(item) == data_to_encode.shape[1]:
880-
len_msg = len_msg.format(
881-
name=name, len_item=len(item), len_enc=data_to_encode.shape[1]
882-
)
883880
raise ValueError(len_msg)
884881

885882
check_len(prefix, "prefix")
@@ -986,8 +983,8 @@ def get_empty_frame(data) -> DataFrame:
986983

987984
# PY2 embedded unicode, gh-22084
988985
def _make_col_name(prefix, prefix_sep, level) -> str:
989-
fstr = "{prefix}{prefix_sep}{level}"
990-
return fstr.format(prefix=prefix, prefix_sep=prefix_sep, level=level)
986+
fstr = f"{prefix}{prefix_sep}{level}"
987+
return fstr
991988

992989
dummy_cols = [_make_col_name(prefix, prefix_sep, level) for level in levels]
993990

0 commit comments

Comments
 (0)