Skip to content

Commit

Permalink
FIX-modin-project#5200: Use squeeze parameter instead of SeriesGroupby
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Petersohn <[email protected]>
  • Loading branch information
devin-petersohn committed Nov 7, 2022
1 parent c30ab4c commit 789a02e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modin/pandas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,15 @@ def __getitem__(self, key):
if is_list_like(key):
make_dataframe = True
else:
key = [key]
if self._as_index:
make_dataframe = False
else:
make_dataframe = True
key = [key]
internal_by = frozenset(self._internal_by)
cols_to_grab = internal_by.union(key)
key = [col for col in self._df.columns if col in cols_to_grab]
if make_dataframe:
internal_by = frozenset(self._internal_by)
if len(internal_by.intersection(key)) != 0:
ErrorMessage.missmatch_with_pandas(
operation="GroupBy.__getitem__",
Expand All @@ -443,8 +445,6 @@ def __getitem__(self, key):
+ "df.groupby(df['by_column'].copy())['by_column']"
),
)
cols_to_grab = internal_by.union(key)
key = [col for col in self._df.columns if col in cols_to_grab]
return DataFrameGroupBy(
self._df[key],
drop=self._drop,
Expand All @@ -459,7 +459,8 @@ def __getitem__(self, key):
"Column lookups on GroupBy with arbitrary Series in by"
+ " is not yet supported."
)
return SeriesGroupBy(
kwargs["squeeze"] = True
return DataFrameGroupBy(
self._df[key],
drop=False,
**kwargs,
Expand Down

0 comments on commit 789a02e

Please sign in to comment.