<p dir="auto">There seems to be a bug when plotting dataframes that has duplicates in a DatetimeIndex. It seems to only be triggered when there is at least one more non-duplicate item in the index as in the first two cases below. These result in a:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="ValueError: Shape of passed values is (1, 3), indices imply (1, 2)"><pre class="notranslate"><span class="pl-v">ValueError</span>: <span class="pl-v">Shape</span> <span class="pl-s1">of</span> <span class="pl-s1">passed</span> <span class="pl-s1">values</span> <span class="pl-c1">is</span> (<span class="pl-c1">1</span>, <span class="pl-c1">3</span>), <span class="pl-s1">indices</span> <span class="pl-en">imply</span> (<span class="pl-c1">1</span>, <span class="pl-c1">2</span>)</pre></div>
<p dir="auto">While the last case seems to be fine.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
    # Case 1: fails 
    df = pandas.DataFrame(
        index = pandas.to_datetime([
            &quot;2002-07-18 13:49:49&quot;,
            &quot;2002-07-18 13:49:49&quot;,
            &quot;2002-07-18 10:38:58&quot;
        ]),
        data = [1, 1, 1]
    )
    df.plot()

    # Case 2: fails
    df = pandas.DataFrame(
        index = pandas.to_datetime([
            &quot;2002-07-19 10:51:29&quot;,
            &quot;2002-07-18 13:49:49&quot;,
            &quot;2002-07-18 13:49:49&quot;,
        ]),
        data = [1, 1, 1]
    )
    df.plot()

    # Case 3: works
    df = pandas.DataFrame(
        index = pandas.to_datetime([
            &quot;2002-07-18 13:49:49&quot;,
            &quot;2002-07-18 13:49:49&quot;,
        ]),
        data = [1, 1]
    )
    df.plot()
"><pre class="notranslate">    <span class="pl-c"># Case 1: fails </span>
    <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>(
        <span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-en">to_datetime</span>([
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
            <span class="pl-s">"2002-07-18 10:38:58"</span>
        ]),
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>]
    )
    <span class="pl-s1">df</span>.<span class="pl-en">plot</span>()

    <span class="pl-c"># Case 2: fails</span>
    <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>(
        <span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-en">to_datetime</span>([
            <span class="pl-s">"2002-07-19 10:51:29"</span>,
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
        ]),
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">1</span>, <span class="pl-c1">1</span>]
    )
    <span class="pl-s1">df</span>.<span class="pl-en">plot</span>()

    <span class="pl-c"># Case 3: works</span>
    <span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>(
        <span class="pl-s1">index</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-en">to_datetime</span>([
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
            <span class="pl-s">"2002-07-18 13:49:49"</span>,
        ]),
        <span class="pl-s1">data</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">1</span>]
    )
    <span class="pl-s1">df</span>.<span class="pl-en">plot</span>()</pre></div>
<p dir="auto">This is with a recent master checkout: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/52a82efe98a52df7a2dbb1208df19622ccdff39c/hovercard" href="https://github.com/pandas-dev/pandas/commit/52a82efe98a52df7a2dbb1208df19622ccdff39c"><tt>52a82ef</tt></a></p>
<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="import pandas

a = pandas.DataFrame({'a': ['0'], 'b': ['str']})

print(a.dtypes)

b = pandas.concat([a, pandas.DataFrame({'b': ['str2']})], axis=1)

print(b.dtypes)

b.iloc[:, 0] = [int(v) for v in a.iloc[:, 0]]

print(b.dtypes)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span>

<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'a'</span>: [<span class="pl-s">'0'</span>], <span class="pl-s">'b'</span>: [<span class="pl-s">'str'</span>]})

<span class="pl-en">print</span>(<span class="pl-s1">a</span>.<span class="pl-s1">dtypes</span>)

<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">pandas</span>.<span class="pl-en">concat</span>([<span class="pl-s1">a</span>, <span class="pl-s1">pandas</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">'b'</span>: [<span class="pl-s">'str2'</span>]})], <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)

<span class="pl-en">print</span>(<span class="pl-s1">b</span>.<span class="pl-s1">dtypes</span>)

<span class="pl-s1">b</span>.<span class="pl-s1">iloc</span>[:, <span class="pl-c1">0</span>] <span class="pl-c1">=</span> [<span class="pl-en">int</span>(<span class="pl-s1">v</span>) <span class="pl-k">for</span> <span class="pl-s1">v</span> <span class="pl-c1">in</span> <span class="pl-s1">a</span>.<span class="pl-s1">iloc</span>[:, <span class="pl-c1">0</span>]]

<span class="pl-en">print</span>(<span class="pl-s1">b</span>.<span class="pl-s1">dtypes</span>)</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">The issue seems to be that if there is a DataFrame with duplicate column names, I cannot modify an (unrelated) column and convert its dtype from object to int.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The final print should be:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a     int64
b    object
b    object
dtype: object"><pre class="notranslate"><code class="notranslate">a     int64
b    object
b    object
dtype: object
</code></pre></div>
<p dir="auto">And not:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a    object
b    object
b    object
dtype: object"><pre class="notranslate"><code class="notranslate">a    object
b    object
b    object
dtype: object
</code></pre></div>
<p dir="auto">It is interesting that if I change concat line to (see renaming of column <code class="notranslate">b</code> to <code class="notranslate">c</code>):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="b = pandas.concat([a, pandas.DataFrame({'c': ['str2']})], axis=1)"><pre class="notranslate"><code class="notranslate">b = pandas.concat([a, pandas.DataFrame({'c': ['str2']})], axis=1)
</code></pre></div>
<p dir="auto">Then the output is correctly:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a     int64
b    object
c    object
dtype: object"><pre class="notranslate"><code class="notranslate">a     int64
b    object
c    object
dtype: object
</code></pre></div>
<p dir="auto">So it seems it has something with the fact that there are duplicate column names on other two columns, not the one being changed.</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: None<br>
python: 3.6.3.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.13.0-46-generic<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.23.3<br>
pytest: None<br>
pip: 18.0<br>
setuptools: 40.0.0<br>
Cython: None<br>
numpy: 1.15.0<br>
scipy: None<br>
pyarrow: None<br>
xarray: None<br>
IPython: None<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.7.3<br>
pytz: 2018.5<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: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: None<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>