<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [2]: pd.DataFrame(index=range(3), columns=[1, 2, float('nan'), 2])[float('nan')]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-2-86ff82017f2a&gt; in &lt;module&gt;()
----&gt; 1 pd.DataFrame(index=range(3), columns=[1, 2, float('nan'), 2])[float('nan')]

/home/nobackup/repo/pandas/pandas/core/frame.py in __getitem__(self, key)
   2685             return self._getitem_multilevel(key)
   2686         else:
-&gt; 2687             return self._getitem_column(key)
   2688 
   2689     def _getitem_column(self, key):

/home/nobackup/repo/pandas/pandas/core/frame.py in _getitem_column(self, key)
   2695 
   2696         # duplicate columns &amp; possible reduce dimensionality
-&gt; 2697         result = self._constructor(self._data.get(key))
   2698         if result.columns.is_unique:
   2699             result = result[key]

/home/nobackup/repo/pandas/pandas/core/internals.py in get(self, item, fastpath)
   4128 
   4129             if isna(item):
-&gt; 4130                 raise TypeError(&quot;cannot label index with a null key&quot;)
   4131 
   4132             indexer = self.items.get_indexer_for([item])

TypeError: cannot label index with a null key

In [3]: pd.DataFrame(index=range(3), columns=[1, 2, float('nan'), 4])[float('nan')]
Out[3]: 
0    NaN
1    NaN
2    NaN
Name: nan, dtype: object

In [4]: pd.Series(index=[1, 2, float('nan'), 2])[float('nan')]
Out[4]: nan
"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">2</span>]: <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-c1">3</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-en">float</span>(<span class="pl-s">'nan'</span>), <span class="pl-c1">2</span>])[<span class="pl-en">float</span>(<span class="pl-s">'nan'</span>)]
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span>
<span class="pl-v">TypeError</span>                                 <span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>)
<span class="pl-c1">&lt;</span><span class="pl-s1">ipython</span><span class="pl-c1">-</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-c1">2</span><span class="pl-c1">-</span><span class="pl-c1">86</span><span class="pl-s1">ff82017f2a</span><span class="pl-c1">&gt;</span> <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>()
<span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-c1">3</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-en">float</span>(<span class="pl-s">'nan'</span>), <span class="pl-c1">2</span>])[<span class="pl-en">float</span>(<span class="pl-s">'nan'</span>)]

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">nobackup</span><span class="pl-c1">/</span><span class="pl-s1">repo</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">frame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">__getitem__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
   <span class="pl-c1">2685</span>             <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_getitem_multilevel</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2686</span>         <span class="pl-s1">else</span>:
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2687</span>             <span class="pl-s1">return</span> <span class="pl-s1">self</span>.<span class="pl-en">_getitem_column</span>(<span class="pl-s1">key</span>)
   <span class="pl-c1">2688</span> 
   <span class="pl-c1">2689</span>     <span class="pl-k">def</span> <span class="pl-en">_getitem_column</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>):

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">nobackup</span><span class="pl-c1">/</span><span class="pl-s1">repo</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">frame</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">_getitem_column</span>(<span class="pl-s1">self</span>, <span class="pl-s1">key</span>)
   <span class="pl-c1">2695</span> 
   <span class="pl-c1">2696</span>         <span class="pl-c"># duplicate columns &amp; possible reduce dimensionality</span>
<span class="pl-c1">-</span><span class="pl-c1">&gt;</span> <span class="pl-c1">2697</span>         <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-en">_constructor</span>(<span class="pl-s1">self</span>.<span class="pl-s1">_data</span>.<span class="pl-en">get</span>(<span class="pl-s1">key</span>))
   <span class="pl-c1">2698</span>         <span class="pl-k">if</span> <span class="pl-s1">result</span>.<span class="pl-s1">columns</span>.<span class="pl-s1">is_unique</span>:
   <span class="pl-c1">2699</span>             <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-s1">result</span>[<span class="pl-s1">key</span>]

<span class="pl-c1">/</span><span class="pl-s1">home</span><span class="pl-c1">/</span><span class="pl-s1">nobackup</span><span class="pl-c1">/</span><span class="pl-s1">repo</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">core</span><span class="pl-c1">/</span><span class="pl-s1">internals</span>.<span class="pl-s1">py</span> <span class="pl-c1">in</span> <span class="pl-en">get</span>(<span class="pl-s1">self</span>, <span class="pl-s1">item</span>, <span class="pl-s1">fastpath</span>)
   <span class="pl-c1">4128</span> 
   <span class="pl-c1">4129</span>             <span class="pl-k">if</span> <span class="pl-en">isna</span>(<span class="pl-s1">item</span>):
<span class="pl-c1">-&gt;</span> <span class="pl-c1">4130</span>                 <span class="pl-k">raise</span> <span class="pl-v">TypeError</span>(<span class="pl-s">"cannot label index with a null key"</span>)
   <span class="pl-c1">4131</span> 
   <span class="pl-c1">4132</span>             <span class="pl-s1">indexer</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">items</span>.<span class="pl-en">get_indexer_for</span>([<span class="pl-s1">item</span>])

<span class="pl-v">TypeError</span>: <span class="pl-s1">cannot</span> <span class="pl-s1">label</span> <span class="pl-s1">index</span> <span class="pl-s1">with</span> <span class="pl-s1">a</span> <span class="pl-s1">null</span> <span class="pl-s1">key</span>

<span class="pl-v">In</span> [<span class="pl-c1">3</span>]: <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-en">range</span>(<span class="pl-c1">3</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-en">float</span>(<span class="pl-s">'nan'</span>), <span class="pl-c1">4</span>])[<span class="pl-en">float</span>(<span class="pl-s">'nan'</span>)]
<span class="pl-v">Out</span>[<span class="pl-c1">3</span>]: 
<span class="pl-c1">0</span>    <span class="pl-v">NaN</span>
<span class="pl-c1">1</span>    <span class="pl-v">NaN</span>
<span class="pl-c1">2</span>    <span class="pl-v">NaN</span>
<span class="pl-v">Name</span>: <span class="pl-s1">nan</span>, <span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>

<span class="pl-v">In</span> [<span class="pl-c1">4</span>]: <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-en">float</span>(<span class="pl-s">'nan'</span>), <span class="pl-c1">2</span>])[<span class="pl-en">float</span>(<span class="pl-s">'nan'</span>)]
<span class="pl-v">Out</span>[<span class="pl-c1">4</span>]: <span class="pl-s1">nan</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">The behavior of <code class="notranslate">DataFrame[np.nan]</code> on non-unique columns makes no particular sense and deviates from the behavior of <code class="notranslate">Series[np.nan]</code>.</p>
<p dir="auto">This is mistakenly tested here:<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/pandas-dev/pandas/blob/636dd01fdacba0c8f0e7b5aaa726165983fc861d/pandas/tests/frame/test_constructors.py#L1665">pandas/pandas/tests/frame/test_constructors.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 1665
      in
      <a data-pjax="true" class="commit-tease-sha" href="/pandas-dev/pandas/commit/636dd01fdacba0c8f0e7b5aaa726165983fc861d">636dd01</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L1665" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="1665"></td>
          <td id="LC1665" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-c"># multiple nans should fail</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">I will push a fix in few minutes.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Same as <code class="notranslate">Out[3]:</code>.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/415012f4f38ca0cf41717c51e49bd2349cba09a8/hovercard" href="https://github.com/pandas-dev/pandas/commit/415012f4f38ca0cf41717c51e49bd2349cba09a8"><tt>415012f</tt></a><br>
python: 3.5.3.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.9.0-6-amd64<br>
machine: x86_64<br>
processor:<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: it_IT.UTF-8<br>
LOCALE: it_IT.UTF-8</p>
<p dir="auto">pandas: 0.24.0.dev0+83.g415012f4f<br>
pytest: 3.5.0<br>
pip: 9.0.1<br>
setuptools: 39.2.0<br>
Cython: 0.25.2<br>
numpy: 1.14.3<br>
scipy: 0.19.0<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.2.1<br>
sphinx: 1.5.6<br>
patsy: 0.5.0<br>
dateutil: 2.7.3<br>
pytz: 2018.4<br>
blosc: None<br>
bottleneck: 1.2.0dev<br>
tables: 3.3.0<br>
numexpr: 2.6.1<br>
feather: 0.3.1<br>
matplotlib: 2.2.2.post1153+gff6786446<br>
openpyxl: 2.3.0<br>
xlrd: 1.0.0<br>
xlwt: 1.3.0<br>
xlsxwriter: 0.9.6<br>
lxml: 4.1.1<br>
bs4: 4.5.3<br>
html5lib: 0.999999999<br>
sqlalchemy: 1.0.15<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.10<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: 0.2.1</p>
</details>
<p dir="auto">When reading a table while specifying duplicate column names - let's say two different names - pandas 0.16.1 will copy the last two columns of the data over and over again.</p>
<p dir="auto">I opened a thread on this here:<br>
<a href="http://stackoverflow.com/questions/31207560/pandas-read-table-with-duplicate-names" rel="nofollow">http://stackoverflow.com/questions/31207560/pandas-read-table-with-duplicate-names</a></p>
<p dir="auto">Is this a bug or an intended behavior?</p>