title: Python/Pandas - Cannot append all rows into a dataframe
body: <p>I have this code</p>
  <pre><code>def expander(input_dataframe, n):
    d = dict(tuple(input_dataframe.groupby(input_dataframe.columns[0])))
    u = input_dataframe['Type'].unique()
    cols = ['Type', 'Variants']
    df2 = pd.DataFrame(columns=cols, index=range(n))
  
    for i in range(len(u)):
      df2 = d[u[i]].copy()
      df2[&quot;Variants&quot;] = np.nan
      df2
    df3 = input_dataframe.append(df2, ignore_index=True)
    print(df3) 
  </code></pre>
  <p>When I run the code with :</p>
  <pre><code>expander(input_dataframe=pd.DataFrame({
      'Type':['iPhone', 'iPhone', 'iPhone', 'iPhone', 'Samsung', 'Samsung', 'Samsung', 'Samsung'],
      'Variants':['12 Mini', '12', '12 Pro', '12 Pro Max', 'S21 FE', 'S21', 'S21+', 'S21 Ultra']
  }), n = 4)
  </code></pre>
  <p>I was expecting the output to be like this :
  <a href="https://i.stack.imgur.com/mQzQJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mQzQJ.png" alt="expectation" /></a></p>
  <p>But instead, what I got was like this :
  <a href="https://i.stack.imgur.com/WY63W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WY63W.png" alt="reality" /></a></p>
  <p>How can I solve this?</p>