Skip to content

assigning list to series with boolean indexing #3235

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
stefsmeets opened this issue Apr 2, 2013 · 6 comments · Fixed by #3236
Closed

assigning list to series with boolean indexing #3235

stefsmeets opened this issue Apr 2, 2013 · 6 comments · Fixed by #3236
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@stefsmeets
Copy link

Whenever a boolean array is used to assign some list or array to another series, it returns "ValueError: Length of replacements must equal series length". This was working fine in pandas 10.0, but broke with 10.1

import pandas as pd
import numpy as np
x = pd.Series(np.arange(10))
sel = x < 5
len(x[sel])
x[sel] = range(5) # doesn't work anymore
x[0:5] = range(5) # works
@jreback
Copy link
Contributor

jreback commented Apr 2, 2013

#3236 will close this, thought I had testing this in #2745 but apparently not

thanks for the report

@jreback
Copy link
Contributor

jreback commented Apr 2, 2013

@Tarlitz this is merged into master, pls try out

@jreback jreback closed this as completed Apr 2, 2013
@stefsmeets
Copy link
Author

@jreback Runs like a charm over my entire code, thx! :)

@jreback
Copy link
Contributor

jreback commented Apr 2, 2013

@Tarlitz good to here..

@jreback
Copy link
Contributor

jreback commented Apr 2, 2013

@Tarlitz also...I would recommend you put the rhs side as a Series in any event (and map the indicies to your values), or a full length ndarray, which reduces the chance that your boolean mask is not 'lined up' with the rhs, just my 2c

@stefsmeets
Copy link
Author

@jreback Thanks for the tip, I'll keep that in mind!

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.

2 participants