Skip to content

Commit

Permalink
Refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach committed Nov 1, 2023
1 parent 5ecfbeb commit 8ce08d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -4439,13 +4439,13 @@ def post_processor(
pass_qs = None

ids, ngroups = self.grouper.group_info
# TODO: Is this hit?
ids = ids[ids >= 0]
if self.dropna:
ids = ids[ids >= 0]
nqs = len(qs)

func = partial(
libgroupby.group_quantile,
labels=ids[ids >= 0],
labels=ids,
qs=qs,
interpolation=interpolation,
starts=starts,
Expand Down
8 changes: 1 addition & 7 deletions pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,6 @@ def _codes_and_uniques(self) -> tuple[npt.NDArray[np.signedinteger], ArrayLike]:
codes = np.where(codes >= na_code, codes + 1, codes)
codes = np.where(na_mask, na_code, codes)

# TODO: Can this be removed?
if not self._observed:
uniques = uniques.reorder_categories(self._orig_cats)

return codes, uniques

elif isinstance(self.grouping_vector, ops.BaseGrouper):
Expand Down Expand Up @@ -998,9 +994,7 @@ def is_in_obj(gpr) -> bool:
groupings.append(Grouping(Index([], dtype="int"), np.array([], dtype=np.intp)))

# create the internals grouper
grouper = ops.BaseGrouper(
group_axis, groupings, sort=sort, dropna=dropna, observed=observed
)
grouper = ops.BaseGrouper(group_axis, groupings, sort=sort, dropna=dropna)
return grouper, frozenset(exclusions), obj


Expand Down
4 changes: 0 additions & 4 deletions pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,13 @@ def __init__(
groupings: Sequence[grouper.Grouping],
sort: bool = True,
dropna: bool = True,
# TODO: Is this still needed?
observed: bool = True,
) -> None:
assert isinstance(axis, Index), axis

self.axis = axis
self._groupings: list[grouper.Grouping] = list(groupings)
self._sort = sort
self.dropna = dropna
self.observed = observed

@property
def groupings(self) -> list[grouper.Grouping]:
Expand Down Expand Up @@ -859,7 +856,6 @@ def result_index_and_ids(self) -> tuple[Index, np.ndarray]:

return result_index, ids

# TODO: How is this different from .levels?
@final
def get_group_levels(self) -> list[Index]:
# Note: only called from _insert_inaxis_grouper, which
Expand Down

0 comments on commit 8ce08d1

Please sign in to comment.