-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: array-like quantile fails on column groupby #38173
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
Changes from 4 commits
5da8e96
7e735ac
95f0afe
8a41c03
d26c36c
c0e629a
e9a7c15
55c9a19
673d008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2227,6 +2227,7 @@ def post_processor(vals: np.ndarray, inference: Optional[Type]) -> np.ndarray: | |
) | ||
for qi in q | ||
] | ||
if self.axis == 0: | ||
result = concat(results, axis=0, keys=q) | ||
# fix levels to place quantiles on the inside | ||
# TODO(GH-10710): Ideally, we could write this as | ||
|
@@ -2250,6 +2251,22 @@ def post_processor(vals: np.ndarray, inference: Optional[Type]) -> np.ndarray: | |
# reorder rows to keep things sorted | ||
indices = np.arange(len(result)).reshape([len(q), self.ngroups]).T.flatten() | ||
return result.take(indices) | ||
else: | ||
result = concat(results, axis=1, keys=q) | ||
|
||
order = list(range(1, result.columns.nlevels)) + [0] | ||
index_names = np.array(result.columns.names) | ||
result.columns.names = np.arange(len(index_names)) | ||
result = result.reorder_levels(order, axis=1) | ||
result.columns.names = index_names[order] | ||
indices = ( | ||
np.arange(result.shape[1]) | ||
.reshape( | ||
[len(q), self.ngroups], | ||
) | ||
.T.flatten() | ||
) | ||
return result.take(indices, axis=1) | ||
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. could a lot of this be shared with the axis=0 version by replacing result.columns with 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. sounds good, I will change this. |
||
|
||
@Substitution(name="groupby") | ||
def ngroup(self, ascending: bool = True): | ||
|
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.
extra period snuck in