Skip to content

Setting a value in a categorical column using boolean indexing fails for large index values #9554

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
coroa opened this issue Feb 25, 2015 · 1 comment
Labels
Bug Categorical Categorical Data Type
Milestone

Comments

@coroa
Copy link
Contributor

coroa commented Feb 25, 2015

Consider

import pandas as pd

df = pd.DataFrame(dict(A=np.array(range(0, 200)),
                       B=pd.Categorical(['a']*200, categories=['a', 'b'])))

# Setting a categorical with boolean indexing works fine for small indices
print df.loc[df.A == 5]
df.loc[df.A == 5, 'B'] = 'b'
print df.loc[df.A == 5]

print ""

# ... but fails for large indices
print df.loc[df.A == 150]
df.loc[df.A == 150, 'B'] = 'b'
print df.loc[df.A == 150]

outputs at my pandas 0.15.1.dev installation (note that the value is correctly updated for A==5, but not for A==150):

   A  B
5  5  a
   A  B
5  5  b

       A  B
150  150  a
       A  B
150  150  a
@jreback
Copy link
Contributor

jreback commented Feb 25, 2015

this was fixed in #9469
it will be in the upcoming 0.16.0 release and is in master now.

@jreback jreback closed this as completed Feb 25, 2015
@jreback jreback added Bug Categorical Categorical Data Type labels Feb 25, 2015
@jreback jreback added this to the 0.16.0 milestone Feb 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type
Projects
None yet
Development

No branches or pull requests

2 participants