BUG: series assignment with a boolean indexer #2686

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

jreback commented Jan 11, 2013

  • fixed assignment with a boolean indexer and a non-scalar as the value (see below)
  • 2nd commit fixed the alignment issue; that is if the value is not a full series, align first (using where machinery)
  • add neg and inv methods
  • _check_bool_indexer now coerces to bool if needed (otherwise weird effects when doing neg/inv on boolean series)
In [1]: import numpy as np

In [2]: import pandas as pd

In [3]: x = pd.Series(index=np.arange(10))

In [4]: y = pd.Series(np.random.rand(10),index=np.arange(10))

In [5]: y
Out[5]: 
0    0.197830
1    0.134425
2    0.766618
3    0.057765
4    0.790927
5    0.153636
6    0.585305
7    0.906787
8    0.647155
9    0.494154

In [6]: x[y>0.5] = y

In [7]: x
Out[7]: 
0         NaN
1         NaN
2    0.197830
3         NaN
4    0.134425
5         NaN
6    0.766618
7    0.057765
8    0.790927
9         NaN

jreback added some commits Jan 11, 2013

@jreback jreback BUG: series assignment with a boolean indexer AND a series as a value…
… would give incorrect results
2fd944f
@jreback jreback ENH: added neg/inv operators to series
     fixed setitem with boolean indexer to accept an object needing alignment (e.g. a partial series)
76d982c
@jreback jreback DOC: update release notes 7ec49f6
Owner

wesm commented Jan 20, 2013

thanks jeff

wesm closed this Jan 20, 2013

wesm was assigned Jan 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment