Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataFrame] Fixing bugs in groupby #2031

Merged
merged 2 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/ray/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,9 @@ def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True,
elif isinstance(by, compat.string_types):
by = self.__getitem__(by).values.tolist()
elif is_list_like(by):
if isinstance(by, pd.Series):
by = by.values.tolist()

mismatch = len(by) != len(self) if axis == 0 \
else len(by) != len(self.columns)

Expand Down
5 changes: 2 additions & 3 deletions python/ray/dataframe/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import print_function

import pandas.core.groupby
import numpy as np
import pandas as pd
from pandas.core.dtypes.common import is_list_like
import ray
Expand Down Expand Up @@ -34,7 +33,7 @@ def __init__(self, df, by, axis, level, as_index, sort, group_keys,
self._index_grouped = pd.Series(self._columns, index=self._index)\
.groupby(by=by, sort=sort)

self._keys_and_values = [(k, np.array(v))
self._keys_and_values = [(k, v)
for k, v in self._index_grouped]

self._grouped_partitions = \
Expand All @@ -44,7 +43,7 @@ def __init__(self, df, by, axis, level, as_index, sort, group_keys,
as_index,
sort,
group_keys,
squeeze) + part,
squeeze) + tuple(part.tolist()),
num_return_vals=len(self))
for part in partitions)))

Expand Down