Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct index when returning Series from
GroupBy.apply()
(#9016)
Closes #8898 Originally, when returning a Series from a `GroupBy.apply()` operation, we would pass in `self.grouping.keys[offsets[:-1]]` as the index, which was meant to grab each unique group key, assuming that `self.grouping.keys` is sorted. However, because it is not sorted, this just ends up grabbing 5 group keys at random. Since we are already calling `GroupBy._grouped()` in this operation, we can use the `group_names` returned by that as the index instead, which is what the result of `self.grouping.keys[offsets[:-1]]` would be if `self.grouping.keys` was sorted. Authors: - Charles Blackmon-Luca (https://github.com/charlesbluca) Approvers: - Michael Wang (https://github.com/isVoid) URL: #9016
- Loading branch information