title: Swap or exchange column names in pandas dataframe with multiple columns
body: <p>I would like to swap (exchange) only column names in pandas, preferably with one-liner. The additional problem is the fact that I have about 100 columns, which causes that I can't reassign all column names, so I would like to replace pairs of selected column names. I don't know the indexes of columns (it will vary), so I must use column names.</p>
  
  <p>I tried following code:</p>
  
  <pre><code>import pandas as pd
  
  probes = {'Spam': [0.0,1.0],
          'Ham': [1.0,0.0],
          'PT011': [0.11,0.21],
          'PT012': [0.12,0.22],
          'PT021': [0.21,0.11],
          'PT022': [0.22,0.12]}
  
  df = pd.DataFrame(probes,columns= ['Spam','Ham','PT011', 'PT012','PT021','PT022'])
  print("Before renaming:\n",df)
  df.rename(columns={'PT011':'PT021', 'PT012':'PT022','PT021':'PT011','PT022':'PT012'}, inplace=True)
  print("After renaming:\n",df)
  </code></pre>
  
  <p>And I got:</p>
  
  <pre><code>Before renaming:
      Spam  Ham  PT011  PT012  PT021  PT022
  0   0.0  1.0   0.11   0.12   0.21   0.22
  1   1.0  0.0   0.21   0.22   0.11   0.12
  After renaming:
      Spam  Ham  PT021  PT022  PT011  PT012
  0   0.0  1.0   0.11   0.12   0.21   0.22
  1   1.0  0.0   0.21   0.22   0.11   0.12
  </code></pre>
  
  <p>But I would expect some simply one-liner to work allowing to swap column names, with no necessity to define both pairs of column names to swap, but to define only one pair of column names, retaining data, with some loc or iloc attribute, like:</p>
  
  <pre><code>df['PT011','PT012']=df['PT021','PT022']
  </code></pre>
  
  <p>with expected output (also proposed order is desired):</p>
  
  <pre><code>   Spam  Ham   PT011  PT012  PT021  PT022
  0   0.0  1.0   0.21   0.22   0.11   0.12
  1   1.0  0.0   0.11   0.12   0.21   0.22
  </code></pre>
  
  <p>The answers shown in:
  <a href="https://stackoverflow.com/questions/11346283/renaming-columns-in-pandas">Renaming columns in pandas</a>, in example:</p>
  
  <pre><code>df.columns = df.columns.str.replace('PT011','PT021')
  </code></pre>
  
  <p>is not suitable for my case, because it still needs to give both pairs of column names or needs to reassign names of all columns and doesn't give desired order of columns.</p>