Renaming columns in a Pandas dataframe with duplicate column names?
<p>I have a df X with columns with duplicate names: </p>

<pre><code>In [77]: X_R
Out[77]: 
      dollars  dollars
   0   0.7085   0.5000
</code></pre>

<p>I want to rename it so that I have: </p>

<pre><code>In [77]: X_R
Out[77]: 
       Retail   Cost
   0   0.7085   0.5000
</code></pre>

<p>Using the Pandas rename function does' work: </p>

<pre><code>X_R.rename(index=str, columns={"dollars": "Retail", "dollars": "Cost"})
</code></pre>

<p>Just gives me two columns named Cost. </p>

<p>How can I rename the columns in this case? </p>