Skip to content

CLN: GH29547 format with f-strings #34399

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 11 commits into from
May 28, 2020
21 changes: 12 additions & 9 deletions pandas/util/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ def validate_axis_style_args(data, args, kwargs, arg_name, method_name):
raise TypeError(msg)

msg = (
"Interpreting call\n\t'.{method_name}(a, b)' as "
"\n\t'.{method_name}(index=a, columns=b)'.\nUse named "
"arguments to remove any ambiguity. In the future, using "
"positional arguments for 'index' or 'columns' will raise "
"a 'TypeError'."
f"Interpreting call\n\t'.{method_name}(a, b)' as "
f"\n\t'.{method_name}(index=a, columns=b)'.\nUse named "
f"arguments to remove any ambiguity. In the future, using "
f"positional arguments for 'index' or 'columns' will raise "
f"a 'TypeError'."
)
warnings.warn(msg.format(method_name=method_name), FutureWarning, stacklevel=4)
warnings.warn(msg, FutureWarning, stacklevel=4)
out[data._get_axis_name(0)] = args[0]
out[data._get_axis_name(1)] = args[1]
else:
Expand Down Expand Up @@ -370,12 +370,15 @@ def validate_percentile(q: Union[float, Iterable[float]]) -> np.ndarray:
------
ValueError if percentiles are not in given interval([0, 1]).
"""
msg = "percentiles should all be in the interval [0, 1]. Try {0} instead."
q_arr = np.asarray(q)
msg = (
f"percentiles should all be in the interval [0, 1]."
f"Try {q_arr / 100.0} instead."
)
if q_arr.ndim == 0:
if not 0 <= q_arr <= 1:
raise ValueError(msg.format(q_arr / 100.0))
raise ValueError(msg)
else:
if not all(0 <= qs <= 1 for qs in q_arr):
raise ValueError(msg.format(q_arr / 100.0))
raise ValueError(msg)
return q_arr