Skip to content

Commit

Permalink
Add client support for SeriesGroupby unique, nsmallest, nlargest (mod…
Browse files Browse the repository at this point in the history
…in-project#63)

* Add client support for SeriesGroupby unique, nsmallest, nlargest

Signed-off-by: Naren Krishna <[email protected]>

---------

Signed-off-by: Naren Krishna <[email protected]>
  • Loading branch information
naren-ponder authored Feb 10, 2023
1 parent 5383ff2 commit a72e66a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modin/core/execution/client/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ def forwarding_method(self, by, *args, **kwargs):
"std",
"sem",
"rank",
"unique",
"nunique",
"median",
"quantile",
Expand All @@ -954,6 +955,8 @@ def forwarding_method(self, by, *args, **kwargs):
"var",
"first",
"last",
"nlargest",
"nsmallest",
}
)

Expand Down
25 changes: 25 additions & 0 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,31 @@ def _iter(self):
for k in (sorted(group_ids) if self._sort else group_ids)
)

def unique(self):
return self._check_index(
self._wrap_aggregation(
type(self._query_compiler).groupby_unique,
numeric_only=False,
)
)

def nlargest(self, n=5, keep="first"):
return self._check_index(
self._wrap_aggregation(
type(self._query_compiler).groupby_nlargest,
agg_kwargs=dict(n=n, keep=keep),
numeric_only=True,
)
)

def nsmallest(self, n=5, keep="first"):
return self._check_index(
self._wrap_aggregation(
type(self._query_compiler).groupby_nsmallest,
agg_kwargs=dict(n=n, keep=keep),
numeric_only=True,
)
)

if IsExperimental.get():
from modin.experimental.cloud.meta_magic import make_wrapped_class
Expand Down

0 comments on commit a72e66a

Please sign in to comment.