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 Mar 16, 2023
1 parent faa80ca commit f9d9b5f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
31 changes: 29 additions & 2 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 Expand Up @@ -4468,7 +4490,9 @@ def str_capitalize(self):
join : {'left', 'right', 'outer', 'inner'}, default: 'left'""",
)
def str_cat(self, others=None, sep=None, na_rep=None, join="left"):
return StrDefault.register(pandas.Series.str.cat)(self, others, sep, na_rep, join)
return StrDefault.register(pandas.Series.str.cat)(
self, others, sep, na_rep, join
)

@doc_utils.doc_str_method(
refer_to="center",
Expand Down Expand Up @@ -4543,7 +4567,9 @@ def str_findall(self, pat, flags=0, **kwargs):
na : object, default: None""",
)
def str_fullmatch(self, pat, case=True, flags=0, na=None):
return StrDefault.register(pandas.Series.str.fullmatch)(self, pat, case, flags, na)
return StrDefault.register(pandas.Series.str.fullmatch)(
self, pat, case, flags, na
)

@doc_utils.doc_str_method(refer_to="get", params="i : int")
def str_get(self, i):
Expand Down Expand Up @@ -5060,6 +5086,7 @@ def expanding_max(self, fold_axis, expanding_args, *args, **kwargs):
return RollingDefault.register(pandas.core.window.expanding.Expanding.max)(
self, expanding_args, *args, **kwargs
)

def expanding_mean(self, fold_axis, expanding_args, *args, **kwargs):
return RollingDefault.register(pandas.core.window.expanding.Expanding.mean)(
self, expanding_args, *args, **kwargs
Expand Down
17 changes: 12 additions & 5 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,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 value_counts(
self,
Expand Down Expand Up @@ -674,10 +678,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 f9d9b5f

Please sign in to comment.