title: Pandas expression causes column explosion (or how to delete columns that contain substring in duplicate names environment)
body: <p>I use the following pandas expression</p>
  
  <pre><code>df = df[df.columns[~df.columns.str.contains('Unnamed:')]]
  </code></pre>
  
  <p>to drop columns that contain Unnamed. I got this one from here 
  <a href="https://stackoverflow.com/questions/43983622/remove-unnamed-columns-in-pandas-dataframe/43983654">Remove Unnamed columns in pandas dataframe</a></p>
  
  <p>For some reason, in some cases, this line causes an explosion of columns 
  e.g</p>
  
  <pre><code>df shape in (2000, 1451)
  after dropping Unnamed (2000, 3851)
  </code></pre>
  
  <p>in particular, it seems like it causes an explosion in case some columns have the same name e.g duplicates.</p>
  
  <p>Anyone knows why this happens and how to avoid it?</p>
  
  <p>How do I drop columns that have certain substring in duplicate-name-allowed case? Thanks </p>