title: How do I make a new data frame from two existing data frames in Pandas?
body: <p>I have two data frames <code>df_att_transposed</code> and <code>df_1</code>. <code>df_1</code> has Supervisor and Name columns. The second data frame, <code>df_att_transposed</code> has attendance for all the names. My first dataframe constructor <code>df_1</code> is -</p>
  <pre><code>{'Sup': {0: 'Sup-1', 1: 'Sup-1', 2: 'Sup-1', 3: 'Sup-1', 4: 'Sup-2',....},'Name': {0: 'Name-1', 1: 'Name-2', 2: 'Name-3'...}}
  </code></pre>
  <p>My second data frame constructor <code>df_att_transposed</code> is -</p>
  <pre><code>{0: {0: Timestamp('2022-01-31 00:00:00'), 1: Timestamp('2022-02-01 00:00:00'), 2: Timestamp('2022-02-02 00:00:00'),...} 1: {0: 'P', 1: 'P', 2: 'P', 3: 'P', 4: 'P'...}}
  </code></pre>
  <p>In my new data frame I am adding the date (the 0th column) and the attendance column of the respective person from <code>df_att_transposed</code>. From <code>df_1</code> I am taking a row at a time containing the name and supervisor in each iteration of a for loop and adding it to all the rows in the data frame. This is how I am making a new dataframe -</p>
  <pre><code>rows = df_1.shape[0]
  for i in range(rows):     
      new_df = df_att_transposed.iloc[:,[0,i+1]].copy()
      new_df['Sup'] = df_1.iloc[i]['Sup']
      new_df['Name'] = df_1.iloc[i]['Name']
  </code></pre>
  <p>The above code adds the data but it only keeps the data from the last iteration in <code>new_df</code>. For every iteration the previous data gets replaced. How can I keep the data from all the iterations together in the new data frame?</p>
  <p><strong>Edit:</strong> (i)The output should look like this -</p>
  <pre><code>Sup     Name       0       1 
  Sup-1   Name-1  28/3/2022  P
  Sup-1   Name-1  27/3/2022  P
  Sup-1   Name-1  26/3/2022  P
  .....
  Sup-2   Name-2  28/3/2022  P
  Sup-2   Name-2  27/3/2022  P
  Sup-2   Name-2  26/3/2022  P
  ......
  </code></pre>
  <p>The code I have written takes a name/row from <code>df_1</code> and two columns from <code>df_att_transposed</code>, writes the data in <code>new_df</code>. Then in the next iteration, another row is taken from <code>df_1</code> and two columns from <code>df_att_transposed</code> again, and the data that was previously stored in <code>new_df</code> gets overwritten. I want the data to be appended in every iteration not replaced.</p>
  <p>(ii) df_att_transposed looks like this(for say 5 employees) -</p>
  <pre><code>       0     1 2 3 4 5 
  0  28/3/2022 P P P P P 
  1  27/3/2022 P P P P P 
  2  26/3/2022 P P P P P 
  ....
  </code></pre>