title: Copying (efficiently) dataframe content inside of another dataframe using Python
body: <p>I have one dataframe (<code>df1</code>):</p>
  
  <p><a href="https://i.stack.imgur.com/eXEeG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eXEeG.png" alt="enter image description here"></a></p>
  
  <p>I then create a new dataframe (<code>df2</code>) which has twice as many rows as <code>fd1</code>. My goal is to copy some elements of the first dataframe inside the second one in a smart way so that the result looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/3Z1jK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Z1jK.png" alt="enter image description here"></a></p>
  
  <p>So far I was able to reach this goal by using the following commands:</p>
  
  <pre><code>raw_data = {'A': ['pinco', 'pallo', 'pollo'], 
              'B': ['lollo', 'fallo', 'gollo'], 
              'C': ['pizzo', 'pazzo', 'razzo']}
  df1 = pd.DataFrame(raw_data, columns = ['A', 'B', 'C'])
  columns = ['XXX','YYY', 'ZZZ']
  N = 3
  df2 = pd.DataFrame(columns=columns,index=range(N*2))
  
  idx = 0
  for i in range(N):
      df2['XXX'].loc[idx] = df1['A'].loc[i]
      df2['XXX'].loc[idx+1] = df1['A'].loc[i]
      df2['YYY'].loc[idx] = df1['B'].loc[i]
      df2['YYY'].loc[idx+1] = df1['C'].loc[i]
      idx += 2
  </code></pre>
  
  <p>However I am looking for a more efficient (more compact and elegant) way to obtain this result. I tried to use the following combination inside of the for loop without success:</p>
  
  <pre><code>df2[['XXX','YYY']].loc[idx] = df1[['A', 'B']].loc[i]
  df2[['XXX','YYY']].loc[idx+1] = df1[['A', 'C']].loc[i]
  </code></pre>