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: iloc(axis=1).__setitem__ ignores axis #45032

Closed
jbrockmendel opened this issue Dec 23, 2021 · 2 comments · Fixed by #45150
Closed

BUG: iloc(axis=1).__setitem__ ignores axis #45032

jbrockmendel opened this issue Dec 23, 2021 · 2 comments · Fixed by #45150
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Dec 23, 2021

import numpy as np
import pandas as pd

arr = np.random.randn(4, 4)
df = pd.DataFrame(arr)
df[4] = "foo"

df.iloc(axis=1)[2] = 3
>>> df
          0         1         2         3    4
0 -0.042240  2.894031  0.086813  0.808991  foo
1  0.141410  1.998173  0.730306 -0.779878  foo
2  3.000000  3.000000  3.000000  3.000000    3
3  0.270897  1.830372  0.533242 -0.147240  foo

Expected Behavior:

>>> df
          0         1  2         3    4
0 -0.042240  2.894031  3  0.808991  foo
1  0.141410  1.998173  3 -0.779878  foo
2  1.611364  1.459234  3  0.572484  foo
3  0.270897  1.830372  3 -0.147240  foo
@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 23, 2021
@mroeschke mroeschke added Indexing Related to indexing on series/frames, not to indexes themselves and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 27, 2021
@Pydare
Copy link
Contributor

Pydare commented Dec 30, 2021

hello. i'm unable to unassign myself from this issue. i attempted but couldn't figure it out. still a newbie in open source contribution. thanks

@ellequelle
Copy link
Contributor

It looks like this is a side-effect of using numpy to validate the indexer in iloc._get_setitem_indexer (see #32257)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants