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] 2D Array Assignment #9928

Closed
aerdem4 opened this issue Dec 17, 2021 · 1 comment · Fixed by #10056
Closed

[BUG] 2D Array Assignment #9928

aerdem4 opened this issue Dec 17, 2021 · 1 comment · Fixed by #10056
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@aerdem4
Copy link

aerdem4 commented Dec 17, 2021

Describe the bug
When I try to set 2D cupy array to some columns of cudf dataframe, it doesn't work correct. I get same value for the whole row. So it is like it is setting one column of 2D array to all columns of cudf dataframe.

Steps/Code to reproduce bug
df[[f"f_{i}" for i in range(n)]] = cp.random.randn(m, n)

Expected behavior
It should correctly set 2D arrays to columns like it can be done in pandas.

Workaround

for i in range(n):
    df[f"f_{i}"] = cp.random.randn(m)

Environment overview (please complete the following information)
Fresh RAPIDS 21.12 conda installation on Ubuntu 20.04

@aerdem4 aerdem4 added Needs Triage Need team to review and classify bug Something isn't working labels Dec 17, 2021
@beckernick
Copy link
Member

beckernick commented Dec 17, 2021

This seems similar to another issue we resolved: #8672 . Perhaps we didn't resolve it for this non-loc setitem API?

import pandas as pd
import numpy as npm, n = 5, 3df = pd.DataFrame({f"f_{i}":range(m) for i in range(n)})
df[[f"f_{i}" for i in range(n)]] = np.random.randn(m, n)
print(df)
        f_0       f_1       f_2
0 -1.145855 -1.925980 -0.888776
1 -1.197261 -0.259193  3.517007
2  0.233636 -0.435549 -1.525251
3 -0.322054 -0.423073 -0.802210
4 -1.017598 -0.881462 -0.382520
import cudf
import numpy as npm, n = 5, 3df = cudf.DataFrame({f"f_{i}":range(m) for i in range(n)})
df[[f"f_{i}" for i in range(n)]] = cp.random.randn(m, n)
print(df)
        f_0       f_1       f_2
0 -0.274912 -0.274912 -0.274912
1 -0.889039 -0.889039 -0.889039
2  0.049632  0.049632  0.049632
3  0.605849  0.605849  0.605849
4  0.766410  0.766410  0.766410

@beckernick beckernick added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Dec 17, 2021
@galipremsagar galipremsagar self-assigned this Dec 17, 2021
rapids-bot bot pushed a commit that referenced this issue Jan 14, 2022
Fixes: #9928 

This PR fixes 2d array assignment in `setitem`

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Michael Wang (https://github.com/isVoid)

URL: #10056
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants