-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: Fix SeriesGroupBy.quantile for nullable integers #33138
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0496516
Convert to numpy
dsaxton 5d7a4a5
Test
dsaxton 0e1a1a9
Note
dsaxton 409dbf4
Format
dsaxton c2f12c9
Hard code
dsaxton 065ce08
Lint
dsaxton 4a8ed58
Nit
dsaxton fd103dc
Merge remote-tracking branch 'upstream/master' into integer-quantile
dsaxton 4a88dab
Move test
dsaxton fcc00cb
Move check
dsaxton bb69e3d
Update test
dsaxton 5364e68
Merge branch 'master' into integer-quantile
jreback 8ef2789
Merge remote-tracking branch 'upstream/master' into integer-quantile
dsaxton 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 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 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 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 |
---|---|---|
|
@@ -1519,6 +1519,30 @@ def test_quantile_missing_group_values_correct_results(): | |
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"values", | ||
[ | ||
pd.array([1, 0, None] * 2, dtype="Int64"), | ||
pd.array([True, False, None] * 2, dtype="boolean"), | ||
], | ||
) | ||
@pytest.mark.parametrize("q", [0.5, [0.0, 0.5, 1.0]]) | ||
def test_groupby_quantile_nullable_array(values, q): | ||
# https://github.com/pandas-dev/pandas/issues/33136 | ||
df = pd.DataFrame({"a": ["x"] * 3 + ["y"] * 3, "b": values}) | ||
result = df.groupby("a")["b"].quantile(q) | ||
|
||
if isinstance(q, list): | ||
idx = pd.MultiIndex.from_product((["x", "y"], q), names=["a", None]) | ||
true_quantiles = [0.0, 0.5, 1.0] | ||
else: | ||
idx = pd.Index(["x", "y"], name="a") | ||
true_quantiles = [0.5] | ||
|
||
expected = pd.Series(true_quantiles * 2, index=idx, name="b") | ||
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. |
||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
# pipe | ||
# -------------------------------- | ||
|
||
|
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.
this is fine for here, but I think we need a generic 'convert_this_to_something_we_can_use_in_cython)` method on EA. @jbrockmendel @jorisvandenbossche @TomAugspurger
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.
As discussed here, i think the
EA.convert_this_to_something_we_can_use_in_cython
is going to look something like_ordinal_values
, at least for methods like quantile that are ordering-based