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: setting values with array in mixed DataFrame disregards order of indexer #40480

Closed
jorisvandenbossche opened this issue Mar 17, 2021 · 1 comment · Fixed by #40764
Closed
Labels
Blocker Blocking issue or pull request for an upcoming release Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@jorisvandenbossche
Copy link
Member

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'

@jorisvandenbossche jorisvandenbossche added Regression Functionality that used to work in a prior pandas version Blocker Blocking issue or pull request for an upcoming release labels Mar 17, 2021
@jorisvandenbossche jorisvandenbossche added this to the 1.3 milestone Mar 17, 2021
@jorisvandenbossche
Copy link
Member Author

An xfailed test is added in #40325 (comment) (pandas/tests/indexing/test_loc.py::TestLoc2::test_loc_setitem_frame_with_reindex_mixed)

@jbrockmendel jbrockmendel added the Indexing Related to indexing on series/frames, not to indexes themselves label Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker Blocking issue or pull request for an upcoming release Indexing Related to indexing on series/frames, not to indexes themselves Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants