title: Drop every nth column in pandas dataframe
body: <p>i have a pandas dataframe where the columns are named like:</p>
  <pre><code>0,1,2,3,4,.....,n
  </code></pre>
  <p>i would like to drop every 3rd column so that i get a new dataframe where i would have the columns like:</p>
  <pre><code>0,1,3,4,6,7,9,.....,n
  </code></pre>
  <p>I have tried like this:</p>
  <pre><code>shape = df.shape[1]
  for i in range(2,shape,3):
      df = df.drop(df.columns[i], axis=1) 
  </code></pre>
  <p>but i get an error saying index is out of bound and i assume this happens because the shape of the dataframe changes when i am dropping the columns. if i just don't store the output of the &quot;for&quot; loop, then the code works but i don't get my new dataframe.</p>
  <p>How do i solve this?
  Thanks</p>