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

Access self.index instead of self._index where possible #15781

Merged
merged 9 commits into from
May 22, 2024
216 changes: 123 additions & 93 deletions python/cudf/cudf/core/dataframe.py

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions python/cudf/cudf/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def nth(self, n):

result = result[sizes > n]

result._index = self.obj.index.take(
result.index = self.obj.index.take(
result._data["__groupbynth_order__"]
)
del result._data["__groupbynth_order__"]
Expand Down Expand Up @@ -1029,7 +1029,7 @@ def ngroup(self, ascending=True):
if has_null_group:
group_ids.iloc[-1] = cudf.NA

group_ids._index = index
group_ids.index = index
return self._broadcast(group_ids)

def sample(
Expand Down Expand Up @@ -1199,7 +1199,7 @@ def deserialize(cls, header, frames):

def _grouped(self, *, include_groups: bool = True):
offsets, grouped_key_cols, grouped_value_cols = self._groupby.groups(
[*self.obj._index._columns, *self.obj._columns]
[*self.obj.index._columns, *self.obj._columns]
)
grouped_keys = cudf.core.index._index_from_data(
dict(enumerate(grouped_key_cols))
Expand Down Expand Up @@ -2839,8 +2839,8 @@ def _handle_label(self, by):
self._key_columns.append(self._obj._data[by])
except KeyError as e:
# `by` can be index name(label) too.
if by in self._obj._index.names:
self._key_columns.append(self._obj._index._data[by])
if by in self._obj.index.names:
self._key_columns.append(self._obj.index._data[by])
else:
raise e
self.names.append(by)
Expand Down
Loading
Loading