-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Centralised _check_percentile #27584
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
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
69ef619
CLN: Centralised _check_percentile
hedonhermdev 715ac7d
Annotated check_percentile function.
hedonhermdev de8a4ab
Update pandas/core/algorithms.py
hedonhermdev 7db44a4
Fixed typing error in check_percentile.
hedonhermdev 350a624
Refactored docstring of check_percentile function.
hedonhermdev 4b4ca39
Fixed PEP8 issues.
hedonhermdev 79c407d
CLN: Centralised _check_percentile
hedonhermdev 146ebc5
Merge branch 'small-refactor' of https://github.com/hedonhermdev/pand…
hedonhermdev 8807706
Merge branch 'master' into small-refactor
hedonhermdev b0a02e4
Update generic.py
hedonhermdev d4d0e88
Fixed typing error
hedonhermdev 7870f75
check_percentile docstring updated
hedonhermdev 93a7970
Moved check_percentile to utils/_validators.py as validate_percentile.
hedonhermdev 5b0122f
Cleanup
hedonhermdev 946ee3f
Fixed cleanup.
hedonhermdev 3c56c6b
Fixed import in algorithms.
hedonhermdev 786e172
Whitespace issues.
hedonhermdev d81a08d
Linting issues
hedonhermdev 631a049
Fixed linting issues.
hedonhermdev f66f314
Extra quotation.
hedonhermdev 4e399c6
Linting issues.
hedonhermdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1105,6 +1105,22 @@ def _get_score(at): | |
return result | ||
|
||
|
||
def check_percentile(q): | ||
""" | ||
Validate percentiles (used by describe and quantile). | ||
hedonhermdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
|
||
msg = "percentiles should all be in the interval [0, 1]. " "Try {0} instead." | ||
q = np.asarray(q) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just create a new variable here |
||
if q.ndim == 0: | ||
if not 0 <= q <= 1: | ||
raise ValueError(msg.format(q / 100.0)) | ||
else: | ||
if not all(0 <= qs <= 1 for qs in q): | ||
raise ValueError(msg.format(q / 100.0)) | ||
return q | ||
|
||
|
||
# --------------- # | ||
# select n # | ||
# --------------- # | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you annotate this function? I think
q
should just befloat, Iterable[float]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return should be an ndarray
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.