Skip to content

Commit

Permalink
FIX-#6152: make numeric_only default to True (#6162)
Browse files Browse the repository at this point in the history
Signed-off-by: Rehan Durrani <[email protected]>
  • Loading branch information
RehanSD authored May 22, 2023
1 parent dbafac0 commit b1dc45c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,20 @@ def rolling(self, *args, **kwargs):
def hist(self):
return self._default_to_pandas(lambda df: df.hist())

def quantile(self, q=0.5, interpolation="linear"):
# TODO: pandas 1.5 now supports numeric_only as an argument
def quantile(self, q=0.5, interpolation="linear", numeric_only=no_default):
# TODO: handle list-like cases properly
if numeric_only is no_default:
numeric_only = True
# We normally handle `numeric_only` by masking non-numeric columns; however
# pandas errors out if there are only non-numeric columns and `numeric_only=True`
# for groupby.quantile.
if numeric_only:
if all(
[not is_numeric_dtype(dtype) for dtype in self._query_compiler.dtypes]
):
raise TypeError(
f"'quantile' cannot be performed against '{self._query_compiler.dtypes[0]}' dtypes!"
)
if is_list_like(q):
return self._default_to_pandas(
lambda df: df.quantile(q=q, interpolation=interpolation)
Expand All @@ -1150,7 +1161,7 @@ def quantile(self, q=0.5, interpolation="linear"):
return self._check_index(
self._wrap_aggregation(
type(self._query_compiler).groupby_quantile,
numeric_only=False,
numeric_only=numeric_only,
agg_kwargs=dict(q=q, interpolation=interpolation),
)
)
Expand Down

0 comments on commit b1dc45c

Please sign in to comment.