<p dir="auto">Right now, pandas's read_csv() supports forcing column names read from CSV data to be unique:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import pandas as pd
p&gt;&gt;&gt; pd.__version__
u'0.20.3'
&gt;&gt;&gt; from StringIO import StringIO
&gt;&gt;&gt; csv_data = &quot;&quot;&quot;a,a,b
... 1,2,3
... 4,5,6&quot;&quot;&quot;
&gt;&gt;&gt; df = pd.read_csv(StringIO(csv_data))
&gt;&gt;&gt; df.columns.tolist()
['a', 'a.1', 'b']"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <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-s1">p</span><span class="pl-c1">&gt;&gt;</span><span class="pl-s1"></span><span class="pl-c1">&gt;</span> <span class="pl-s1">pd</span>.<span class="pl-s1">__version__</span>
<span class="pl-s">u'0.20.3'</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">from</span> <span class="pl-v">StringIO</span> <span class="pl-k">import</span> <span class="pl-v">StringIO</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">csv_data</span> <span class="pl-c1">=</span> <span class="pl-s">"""a,a,b</span>
<span class="pl-s">... 1,2,3</span>
<span class="pl-s">... 4,5,6"""</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-v">StringIO</span>(<span class="pl-s1">csv_data</span>))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>.<span class="pl-s1">columns</span>.<span class="pl-en">tolist</span>()
[<span class="pl-s">'a'</span>, <span class="pl-s">'a.1'</span>, <span class="pl-s">'b'</span>]</pre></div>
<p dir="auto">The documentation suggests that passing <code class="notranslate">mangle_dupe_cols=False</code> to <code class="notranslate">read_csv()</code> will change this behavior to one where it'll overwrite data on load. That doesn't seem to be implemented as of this version:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df = pd.read_csv(StringIO(csv_data), mangle_dupe_cols=False)
# snip
ValueError: Setting mangle_dupe_cols=False is not supported yet"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-v">StringIO</span>(<span class="pl-s1">csv_data</span>), <span class="pl-s1">mangle_dupe_cols</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-c"># snip</span>
<span class="pl-v">ValueError</span>: <span class="pl-v">Setting</span> <span class="pl-s1">mangle_dupe_cols</span><span class="pl-c1">=</span><span class="pl-c1">False</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-s1">supported</span> <span class="pl-s1">yet</span></pre></div>
<p dir="auto">However! Pandas doesn't fundamentally disallow duplicate column names. There's a simple (but somewhat convoluted) trick to get duplicate columns from a CSV file into your headers:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df = pd.read_csv(StringIO(csv_data), header=None)
&gt;&gt;&gt; df.columns = df.iloc[0]
&gt;&gt;&gt; df = df.reindex(df.index.drop(0)).reset_index(drop=True)
&gt;&gt;&gt; df
0  a  a  b
0  1  2  3
1  4  5  6"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-v">StringIO</span>(<span class="pl-s1">csv_data</span>), <span class="pl-s1">header</span><span class="pl-c1">=</span><span class="pl-c1">None</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>.<span class="pl-s1">columns</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">df</span>.<span class="pl-s1">index</span>.<span class="pl-en">drop</span>(<span class="pl-c1">0</span>)).<span class="pl-en">reset_index</span>(<span class="pl-s1">drop</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>
<span class="pl-c1">0</span>  <span class="pl-s1">a</span>  <span class="pl-s1">a</span>  <span class="pl-s1">b</span>
<span class="pl-c1">0</span>  <span class="pl-c1">1</span>  <span class="pl-c1">2</span>  <span class="pl-c1">3</span>
<span class="pl-c1">1</span>  <span class="pl-c1">4</span>  <span class="pl-c1">5</span>  <span class="pl-c1">6</span></pre></div>
<p dir="auto">(Then again, maybe this isn't so simple; there's a funny "0" in there with the column headings and that seems weird.)</p>
<h4 dir="auto">Problem description</h4>
<p dir="auto">I would like a native way to read CSV files with repeated headers. In my application, it's literally so I can warn people about duplicated column headers. Yes, I could use python's built-in <code class="notranslate">csv</code> module for this, but then I'm using two methods to read CSV files and it gets weird.</p>
<p dir="auto">Since <code class="notranslate">mangle_dupe_cols=False</code> is not yet implemented, I might propose this behavior in this case.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<blockquote>
<blockquote>
<blockquote>
<p dir="auto">pd.show_versions()</p>
</blockquote>
</blockquote>
</blockquote>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.11.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 17.3.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.20.3<br>
pytest: 3.2.1<br>
pip: 9.0.1<br>
setuptools: 36.2.7<br>
Cython: None<br>
numpy: 1.13.1<br>
scipy: None<br>
xarray: None<br>
IPython: 5.4.1<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: None<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.999999999<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="149815976" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/12935" data-hovercard-type="pull_request" data-hovercard-url="/pandas-dev/pandas/pull/12935/hovercard" href="https://github.com/pandas-dev/pandas/pull/12935">#12935</a> added full support for duplicate column names (in header or in <code class="notranslate">names</code>) by mangling them.  While this has been considered <em>acceptable</em> by users, ideally, we would like to not have to mangle them.</p>