title: Changing column name dynamically in Python
body: <p>I have a dataframe with 50 columns. The problem with index row is that, all of them columns are named to: <strong><em>Unnamed.</em></strong></p>
  
  <p>I want to rename the columns. I know that with dataframes you rename the columnsthis way:</p>
  
  <pre><code>df.rename(columns={"A": "a", "B": "c"})
  </code></pre>
  
  <p>But as I have 50 columns, I want to rename the columns through a loop for learning and efficiencie sake.</p>
  
  <p>I want to rename <strong>column 0</strong> to <code>'Name'</code>, <strong>column 1</strong> to <code>Country</code> and the rest to <code>Group 1, Group 2</code> and so on.</p>
  
  <p>Here is my solution so far for column 3 to 50. I was thinking of renaming the first 2 columns manually as I cannot come with a better way to do within the loop. </p>
  
  <pre><code>for col in df.columns[2:]:
      start = 'Group'
      x = 1
      name = '{}'+x.format(start)
      df = df.rename(columns={col:name})
      x = x+1
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>AttributeError: 'int' object has no attribute 'format'
  </code></pre>
  
  <p>Now I understand that, this is because of the x value. But I'cant come up with a way for the column name to change dynamically for every column.</p>