Skip to content

STYLE/PERF: use f-strings instead of ''.join on static elements #49517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,7 @@ def _make_unique_kwarg_list(
[('a', '<lambda>_0'), ('a', '<lambda>_1'), ('b', '<lambda>')]
"""
return [
(pair[0], "_".join([pair[1], str(seq[:i].count(pair))]))
if seq.count(pair) > 1
else pair
(pair[0], f"{pair[1]}_{seq[:i].count(pair)}") if seq.count(pair) > 1 else pair
for i, pair in enumerate(seq)
]

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/window/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def create_section_header(header: str) -> str:
"""Create numpydoc section header"""
return "\n".join((header, "-" * len(header))) + "\n"
return f"{header}\n{'-' * len(header)}\n"


template_header = "\nCalculate the {window_method} {aggregation_description}.\n\n"
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/css.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ class CSSResolver:

CSS_EXPANSIONS = {
**{
"-".join(["border", prop] if prop else ["border"]): _border_expander(prop)
(f"border-{prop}" if prop else "border"): _border_expander(prop)
for prop in ["", "top", "right", "bottom", "left"]
},
**{
"-".join(["border", prop]): _side_expander("border-{:s}-" + prop)
f"border-{prop}": _side_expander(f"border-{{:s}}-{prop}")
for prop in ["color", "style", "width"]
},
**{
Expand Down