Skip to content
Merged
Changes from 1 commit
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
11 changes: 5 additions & 6 deletions pandas/util/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,13 @@ def validate_percentile(q: Union[float, Iterable[float]]) -> np.ndarray:
ValueError if percentiles are not in given interval([0, 1]).
"""
q_arr = np.asarray(q)
msg = (
"percentiles should all be in the interval [0, 1]."
f"Try {q_arr / 100.0} instead."
)
# Don't change this to an f-string. The string formatting
# is too expensive for cases where we don't need it.
msg = "percentiles should all be in the interval [0, 1]." "Try {} instead."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra quotation marks probably an artifact of black

if q_arr.ndim == 0:
if not 0 <= q_arr <= 1:
raise ValueError(msg)
raise ValueError(msg.format(q_arr / 100.0))
else:
if not all(0 <= qs <= 1 for qs in q_arr):
raise ValueError(msg)
raise ValueError(msg.format(q_arr / 100.0))
return q_arr