Skip to content

BUG: assigment of list with boolean mask scrambles values #30988

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

Closed
jorisvandenbossche opened this issue Jan 13, 2020 · 4 comments
Closed

BUG: assigment of list with boolean mask scrambles values #30988

jorisvandenbossche opened this issue Jan 13, 2020 · 4 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@jorisvandenbossche
Copy link
Member

From gitter (didn't see it reported in an issue):

x = pd.Series([None] * 10)
y = [False] * 3 + [True] * 5 + [False] * 2
x[y] = list(range(5))
x

gives:

0    None
1    None
2    None
3       3
4       4
5       0
6       1
7       2
8    None
9    None
dtype: object

For some reason, the assigned values are not in the correct order.

With an array, it works fine (but I think we support list as well?):

In [4]: x[y] = np.array(list(range(5)))

In [5]: x
Out[5]: 
0    None
1    None
2    None
3       0
4       1
5       2
6       3
7       4
8    None
9    None
dtype: object

Tested on pandas master, and also on pandas 0.25 it is buggy (eg in pandas 0.18 it worked fine).

@jorisvandenbossche jorisvandenbossche added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Jan 13, 2020
@jorisvandenbossche jorisvandenbossche added this to the Contributions Welcome milestone Jan 13, 2020
@TomAugspurger
Copy link
Contributor

I thought we had an issue for this, but am not finding it right now. Perhaps I'm remembering the gitter conversation.

@jorisvandenbossche
Copy link
Member Author

I checked the issues since the gitter discussion, and didn't see one about this (at least not in the open issues)

@jreback
Copy link
Contributor

jreback commented Jan 14, 2020

#30580

loooks similar / same

was already merged

@jorisvandenbossche
Copy link
Member Author

Ah, I should have checked the closed ones as well ;)

Closing as duplicate of #30567

@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, No action Jan 14, 2020
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

No branches or pull requests

3 participants