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

[] (__getitem__) boolean indexing assignment bug with nans #9731

Closed
skellys opened this issue Mar 25, 2015 · 0 comments · Fixed by #9743
Closed

[] (__getitem__) boolean indexing assignment bug with nans #9731

skellys opened this issue Mar 25, 2015 · 0 comments · Fixed by #9743
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@skellys
Copy link

skellys commented Mar 25, 2015

See repro below:

import pandas as pd
import numpy as np

temp = pd.Series(np.random.randn(10))
temp[3:6] = np.nan
temp[8] = np.nan
nan_index = np.isnan(temp)

# this works
temp1 = temp.copy()
temp1[nan_index] = [99, 99, 99, 99]
temp1[nan_index]

3    99
4    99
5    99
8    99
dtype: float64

# this doesn't - values look like they're being assigned in a different order?
temp2 = temp.copy()
temp2[nan_index] = [99, 99, 99, np.nan]

3   NaN
4    99
5    99
8    99
dtype: float64

# ... but it works properly when using .loc
temp2 = temp.copy()
temp2.loc[nan_index] = [99, 99, 99, np.nan]

3    99
4    99
5    99
8   NaN
dtype: float64

output of show_versions():

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.16.0
nose: 1.3.4
Cython: 0.21.2
numpy: 1.9.2
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 3.0.0
sphinx: 1.2.3
patsy: 0.2.1
dateutil: 2.4.1
pytz: 2015.2
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.3.1
matplotlib: 1.4.0
openpyxl: 2.0.2
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.6.6
lxml: 3.4.2
bs4: 4.3.2
html5lib: 0.999
httplib2: 0.8
apiclient: None
sqlalchemy: 0.9.8
pymysql: None
psycopg2: None
@jreback jreback added the Bug label Mar 25, 2015
@jreback jreback added this to the 0.16.1 milestone Mar 25, 2015
@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Mar 25, 2015
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