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

[BUG] cudf.pivot doesn't understand "values" #10529

Closed
KazukiOnodera opened this issue Mar 29, 2022 · 1 comment · Fixed by #11538
Closed

[BUG] cudf.pivot doesn't understand "values" #10529

KazukiOnodera opened this issue Mar 29, 2022 · 1 comment · Fixed by #11538
Assignees
Labels
bug Something isn't working good first issue Good for newcomers Python Affects Python cuDF API.

Comments

@KazukiOnodera
Copy link

Describe the bug
cudf.pivot doesn't understand "values" when it's column name instead of list and the column name includes numeric

Steps/Code to reproduce bug

import cudf
df = cudf.DataFrame([
    ['A', 'a', 0, 0, 0],
    ['A', 'b', 1, 1, 1],
    ['A', 'c', 2, 2, 2],
    ['B', 'a', 0, 0, 0],
    ['B', 'b', 1, 1, 1],
    ['B', 'c', 2, 2, 2],
    ['C', 'a', 0, 0, 0],
    ['C', 'b', 1, 1, 1],
    ['C', 'c', 2, 2, 2],
], columns=['x', 'y', 'z', 'z123', '123z'])

This works
cudf.pivot(df, index='x', columns='y', values='z')

This doesn't work
cudf.pivot(df, index='x', columns='y', values='z123')

KeyError Traceback (most recent call last)
Input In [18], in
----> 1 cudf.pivot(df, index="x", columns="y", values="z123")

File ~/anaconda3/envs/rapids-22.02/lib/python3.8/site-packages/cudf/core/reshape.py:924, in pivot(data, index, columns, values)
920 values = df._columns_view(
921 col for col in df._column_names if col not in (index, columns)
922 )
923 else:
--> 924 values = df._columns_view(values)
925 if index is None:
926 index = df.index

File ~/anaconda3/envs/rapids-22.02/lib/python3.8/site-packages/cudf/core/dataframe.py:5580, in DataFrame._columns_view(self, columns)
5575 def _columns_view(self, columns):
5576 """
5577 Return a subset of the DataFrame's columns as a view.
5578 """
5579 return DataFrame(
-> 5580 {col: self._data[col] for col in columns}, index=self.index
5581 )

File ~/anaconda3/envs/rapids-22.02/lib/python3.8/site-packages/cudf/core/dataframe.py:5580, in (.0)
5575 def _columns_view(self, columns):
5576 """
5577 Return a subset of the DataFrame's columns as a view.
5578 """
5579 return DataFrame(
-> 5580 {col: self._data[col] for col in columns}, index=self.index
5581 )

File ~/anaconda3/envs/rapids-22.02/lib/python3.8/site-packages/cudf/core/column_accessor.py:156, in ColumnAccessor.getitem(self, key)
155 def getitem(self, key: Any) -> ColumnBase:
--> 156 return self._data[key]

KeyError: '1'

This works
cudf.pivot(df, index='x', columns='y', values=['z123'])

This works
cudf.pivot(df, index='x', columns='y', values=['z', 'z123', '123z'])

Environment overview
cudf version is "22.02.00"

@KazukiOnodera KazukiOnodera added Needs Triage Need team to review and classify bug Something isn't working labels Mar 29, 2022
@github-actions github-actions bot added this to Needs prioritizing in Bug Squashing Mar 29, 2022
@shwina shwina added Python Affects Python cuDF API. good first issue Good for newcomers and removed Needs Triage Need team to review and classify labels Mar 29, 2022
@shwina shwina self-assigned this Apr 19, 2022
@shwina shwina removed this from Needs prioritizing in Bug Squashing Apr 19, 2022
@shwina shwina added this to Issue-Needs prioritizing in v22.06 Release via automation Apr 19, 2022
@shwina shwina moved this from Issue-Needs prioritizing to Issue-P1 in v22.06 Release Apr 19, 2022
@shwina shwina removed their assignment Apr 19, 2022
@caryr35 caryr35 added this to Issue-Needs prioritizing in v22.08 Release via automation Jun 16, 2022
@caryr35 caryr35 moved this from Issue-Needs prioritizing to Issue-P1 in v22.08 Release Jun 16, 2022
@caryr35 caryr35 removed this from Issue-P1 in v22.06 Release Jun 16, 2022
@caryr35 caryr35 added this to Issue-Needs prioritizing in v22.10 Release via automation Aug 11, 2022
@caryr35 caryr35 moved this from Issue-Needs prioritizing to Issue-P1 in v22.10 Release Aug 11, 2022
@caryr35 caryr35 removed this from Issue-P1 in v22.08 Release Aug 11, 2022
@shaswat-indian
Copy link
Contributor

I'm taking this up.

v22.10 Release automation moved this from Issue-P1 to Done Aug 22, 2022
rapids-bot bot pushed a commit that referenced this issue Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Python Affects Python cuDF API.
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants