Skip to content

BUG: setting values with array in mixed DataFrame disregards order of indexer #40480

Closed
@jorisvandenbossche

Description

@jorisvandenbossche
In [2]: df = DataFrame(index=[3, 5, 4], columns=["A", "B"], dtype=float)
   ...: df["B"] = "string"
   ...: df.loc[[4, 3, 5], "A"] = np.array([1, 2, 3], dtype="int64")

In [3]: df
Out[3]: 
   A       B
3  1  string
5  2  string
4  3  string

In the above (using master), the values [1, 2, 3] were set in that order, while the indexer used a different order. In released versions of pandas, we correctly get [2, 3, 1]:

In [3]: df
Out[3]: 
   A       B
3  2  string
5  3  string
4  1  string

In [4]: pd.__version__
Out[4]: '1.2.3'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BlockerBlocking issue or pull request for an upcoming releaseIndexingRelated to indexing on series/frames, not to indexes themselvesRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions