<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<p dir="auto">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.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
import numpy as np
df = pd.DataFrame(np.arange(1,5).reshape(2,2), columns=[&quot;A&quot;]*2)
# this works like expected
df.iloc[0,0] = -1
df"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">1</span>,<span class="pl-c1">5</span>).<span class="pl-en">reshape</span>(<span class="pl-c1">2</span>,<span class="pl-c1">2</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">"A"</span>]<span class="pl-c1">*</span><span class="pl-c1">2</span>)
<span class="pl-c"># this works like expected</span>
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>,<span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-c1">-</span><span class="pl-c1">1</span>
<span class="pl-s1">df</span></pre></div>
<div dir="auto">
<table border="1" role="table">
  <thead>
    <tr>
      <th></th>
      <th>A</th>
      <th>A</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-1</td>
      <td>2</td>
    </tr>
    <tr>
      <th>1</th>
      <td>3</td>
      <td>4</td>
    </tr>
  </tbody>
</table>
</div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# this sets the entire row to NaN
df.iloc[1,0] = np.nan
df"><pre class="notranslate"><span class="pl-c"># this sets the entire row to NaN</span>
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">1</span>,<span class="pl-c1">0</span>] <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">nan</span>
<span class="pl-s1">df</span></pre></div>
<div dir="auto">
<table border="1" role="table">
  <thead>
    <tr>
      <th></th>
      <th>A</th>
      <th>A</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-1.0</td>
      <td>2.0</td>
    </tr>
    <tr>
      <th>1</th>
      <td>NaN</td>
      <td>NaN</td>
    </tr>
  </tbody>
</table>
</div>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# It only seems to be an issue when indexing the first repeated column
df.iloc[0,1] = np.nan
df"><pre class="notranslate"><span class="pl-c"># It only seems to be an issue when indexing the first repeated column</span>
<span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>,<span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">nan</span>
<span class="pl-s1">df</span></pre></div>
<div dir="auto">
<table border="1" role="table">
  <thead>
    <tr>
      <th></th>
      <th>A</th>
      <th>A</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-1.0</td>
      <td>NaN</td>
    </tr>
    <tr>
      <th>1</th>
      <td>NaN</td>
      <td>NaN</td>
    </tr>
  </tbody>
</table>
</div>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><code class="notranslate">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
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Pandas version 0.17.1
import pandas as pd
df = pd.DataFrame({'Same': 1.0, ' Same': pd.np.nan, '  Same': pd.np.nan}, index=[0,1,2])
df.columns = [c.strip() for c in df.columns]
df.iloc[:, 2] # Returns all 1.0

df.iloc[:, 0] = df.iloc[:, 0].fillna(df.iloc[:, 1])

df.iloc[:, 2] # Column 2 is corrupted and returns all NaN"><pre class="notranslate"><code class="notranslate"># Pandas version 0.17.1
import pandas as pd
df = pd.DataFrame({'Same': 1.0, ' Same': pd.np.nan, '  Same': pd.np.nan}, index=[0,1,2])
df.columns = [c.strip() for c in df.columns]
df.iloc[:, 2] # Returns all 1.0

df.iloc[:, 0] = df.iloc[:, 0].fillna(df.iloc[:, 1])

df.iloc[:, 2] # Column 2 is corrupted and returns all NaN
</code></pre></div>