Skip to content

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

Closed
@jbrockmendel

Description

@jbrockmendel
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions