title: How to avoid the assigned value being re-written?
body: <p>The assignment happens appropriately for each category, but if the blocks get full and there are IDs pending in the category and we assign them to a new block, the old assignments get rewritten. Also how do I print the whole new dataframe at the end, because when I am trying it only shows the D block assignment...</p>
  <pre><code>import pandas as pd
  data = pd.read_csv(&quot;database.csv&quot;)
  
  blocks = {&quot;A&quot;: 5, &quot;B&quot;: 30, &quot;C&quot;: 50, &quot;D&quot;: 100}
  for key, value in blocks.items():
      print(&quot;For block &quot; + key + &quot; capacity is &quot; + str(value))
      while True:
          s = input(&quot;Which category to be allocated? &quot;)
          dataFrame = data[data['Category'].str.contains(s)]
          if not dataFrame.empty:
              dataFrame['Block'] = key
  
              # for loop for Sr. Number
              spc = blocks[key]
              i = 1
              for index, row in dataFrame.iterrows():
                  if i &gt; spc:
                      break
                  dataFrame.loc[index, 'Sr.'] = str(i)
                  i += 1
              print(dataFrame)
              break
  
  print(dataFrame)
  
  
  This is the input 
  Name,ID,Category 
  ABC,2020,G 
  WER,2021,M 
  XCV,2022,T 
  GFV,2034,M 
  WEQ,2021,M 
  WEW,2021,M 
  WET,2021,M 
  WEY,2021,M 
  WLK,2021,M 
  WYH,2021,M 
  
  expected output 
  Name,ID,Category,Block, Sr. 
  1 WER 2021 M A 1 
  3 GFV 2034 M A 2 
  4 WEQ 2021 M A 3 
  5 WEW 2021 M A 4 
  6 WET 2021 M A 5 
  
  7 WEY 2021 M B 1
  8 WLK 2021 M B 2
  9 WYH 2021 M B 3
  </code></pre>