Closed
Description
Code Sample, a copy-pastable example if possible
Something goes wrong when I try to set a NaN value using the iloc syntax. Instead of just the entry being set, the entire row gets set.
import pandas as pd
import numpy as np
df = pd.DataFrame(np.arange(1,5).reshape(2,2), columns=["A"]*2)
# this works like expected
df.iloc[0,0] = -1
df
A | A | |
---|---|---|
0 | -1 | 2 |
1 | 3 | 4 |
# this sets the entire row to NaN
df.iloc[1,0] = np.nan
df
A | A | |
---|---|---|
0 | -1.0 | 2.0 |
1 | NaN | NaN |
# It only seems to be an issue when indexing the first repeated column
df.iloc[0,1] = np.nan
df
A | A | |
---|---|---|
0 | -1.0 | NaN |
1 | NaN | NaN |
output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 21.2.2
Cython: 0.24
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 4.1.2
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
pandas_datareader: None