title: Randomly allot values to the rows in python
body: <p>I have the following input table (y):</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>parameter1</th>
  <th>parameter2</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>12</td>
  </tr>
  <tr>
  <td>2</td>
  <td>23</td>
  </tr>
  <tr>
  <td>3</td>
  <td>66</td>
  </tr>
  <tr>
  <td>4</td>
  <td>98</td>
  </tr>
  <tr>
  <td>5</td>
  <td>90</td>
  </tr>
  <tr>
  <td>6</td>
  <td>14</td>
  </tr>
  <tr>
  <td>7</td>
  <td>7</td>
  </tr>
  <tr>
  <td>8</td>
  <td>56</td>
  </tr>
  <tr>
  <td>9</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I would like to randomly allot values from A1 to A9. The output table should look like the following:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>parameter1</th>
  <th>parameter2</th>
  <th>parameter3</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>12</td>
  <td>A5</td>
  </tr>
  <tr>
  <td>2</td>
  <td>23</td>
  <td>A2</td>
  </tr>
  <tr>
  <td>3</td>
  <td>66</td>
  <td>A4</td>
  </tr>
  <tr>
  <td>4</td>
  <td>98</td>
  <td>A8</td>
  </tr>
  <tr>
  <td>5</td>
  <td>90</td>
  <td>A3</td>
  </tr>
  <tr>
  <td>6</td>
  <td>14</td>
  <td>A7</td>
  </tr>
  <tr>
  <td>7</td>
  <td>7</td>
  <td>A1</td>
  </tr>
  <tr>
  <td>8</td>
  <td>56</td>
  <td>A9</td>
  </tr>
  <tr>
  <td>9</td>
  <td>1</td>
  <td>A6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <pre><code>n = 9
  
  TGn = round(len(y)/n)
  idx = set(y.index // TGn)
  
  y = y.apply(lambda x: x.sample(frac=1,random_state=1234)).reset_index(drop=True)
      
  treatment_groups = [f&quot;A{i}&quot; for i in range(1, n+1)]
  y['groupAfterRandomization'] = (y.index // TGn).map(dict(zip(idx, treatment_groups)))
  </code></pre>
  <p>I am unable to fill the first row value it prints as NaN. How do I tackle this problem?</p>