title: How to Rename Multiple Columns on a Reset Index with Pandas
body: <p>I'm trying to figure out if there is a way to rename Pandas columns when you try to reset the index.  I see in the documentation that you can use the &quot;name&quot; parameter to set the column name of a reset index if there is only one column, but I'm curious if there is a way to do this for multiple columns.</p>
  <p>For example:</p>
  <pre><code>df1 = pd.DataFrame({
  'A' : ['a1', 'a1', 'a2', 'a3'],
  'B' : ['b1', 'b2', 'b3', 'b4'],
  'D1' : [1,0,0,0],
  'D2' : [0,1,1,0],
  'D3' : [0,0,1,1],
  })
  
  df1.set_index(['B','A']).stack().reset_index()
  </code></pre>
  <p>The result leaves you with:</p>
  <pre><code>     B   A level_2  0
  0   b1  a1      D1  1
  1   b1  a1      D2  0
  2   b1  a1      D3  0
  3   b2  a1      D1  0
  4   b2  a1      D2  1
  </code></pre>
  <p>You could do:</p>
  <pre><code>df1.set_index(['B','A']).stack().reset_index(name='my_col')
  </code></pre>
  <p>In order to set the name of the last column but I'm wondering if there is a way to use the parameter to set the name of the 'level_2' column as well.</p>
  <p>The first thing that came to my mind was to try:</p>
  <pre><code>df1.set_index(['B','A']).stack().reset_index(name=['my_col2','my_col'])
  </code></pre>
  <p>However, that did not work so looking for another way around.  I realize I could always just rename the columns in the next line but was hoping there'd be a cleaner way to do it in one line.</p>