Skip to content

Commit

Permalink
Add QC method for groupby.sem (modin-project#47) (core)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrito authored and vnlitvinov committed Apr 17, 2023
1 parent 44e2fd6 commit e738f7d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
22 changes: 22 additions & 0 deletions modin/core/storage_formats/base/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2975,6 +2975,28 @@ def groupby_std(
drop=drop,
)

@doc_utils.doc_groupby_method(
action="compute standard error", result="standard error", refer_to="sem"
)
def groupby_sem(
self,
by,
axis,
groupby_kwargs,
agg_args,
agg_kwargs,
drop=False,
):
return self.groupby_agg(
by=by,
agg_func="sem",
axis=axis,
groupby_kwargs=groupby_kwargs,
agg_args=agg_args,
agg_kwargs=agg_kwargs,
drop=drop,
)

@doc_utils.doc_groupby_method(
action="compute numerical rank", result="numerical rank", refer_to="rank"
)
Expand Down
17 changes: 12 additions & 5 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ def ffill(self, limit=None):
return self._default_to_pandas(lambda df: df.ffill(limit=limit))

def sem(self, ddof=1):
return self._default_to_pandas(lambda df: df.sem(ddof=ddof))
return self._wrap_aggregation(
type(self._query_compiler).groupby_sem,
agg_kwargs=dict(ddof=ddof),
numeric_only=True,
)

def sample(self, n=None, frac=None, replace=False, weights=None, random_state=None):
return self._default_to_pandas(
Expand Down Expand Up @@ -690,10 +694,13 @@ def do_relabel(obj_to_relabel):
kwargs = {}
func = func_dict
elif is_list_like(func):
return self._default_to_pandas(
lambda df, *args, **kwargs: df.aggregate(func, *args, **kwargs),
*args,
**kwargs,
return self._wrap_aggregation(
qc_method=type(self._query_compiler).groupby_agg,
numeric_only=False,
agg_func=func,
agg_args=args,
agg_kwargs=kwargs,
how="axis_wise",
)
elif callable(func):
return self._check_index(
Expand Down

0 comments on commit e738f7d

Please sign in to comment.