title: python: iteration continues until next comparison meets a condition
body: <p>I have a project like the following:</p>
  <pre><code>my_project:
    |__my_new_data
    |      |__new_data.csv
    |
    |__my_original_data
    |      |__original_data.csv
    |__process.py
    |
    |__read.py
  </code></pre>
  <p>I have a function in my read.py that reads the new_data.csv and then I import the final dataframe in my process.py to process the data and replace the new_data.csv file in my_new_data_directory in an iterative process. (corrected code taken from the link below)</p>
  <blockquote>
  <p><a href="https://stackoverflow.com/questions/69464311/python-continue-iteration-until-a-certain-condition-is-met">python: continue iteration until a certain condition is met</a></p>
  </blockquote>
  <pre><code>from typing import Final
  
  def iteration():
      data= []
      my_new_data = pd.read_csv((os.path.join(my_new_data, 'new_data.csv')))
      my_original_data = pd.read_csv((os.path.join(my_original_data, 'original_data.csv'))) 
      all_data = pd.concat([my_new_data, my_original_data])
      all_data.drop_duplicates(subset=&quot;text&quot;, keep=False, inplace=True)
      len_first_comb: Final = len(all_data)
      len_iterated_data = len(all_data)
      
      while len_iterated_data &gt; len_first_comb:
          data.append(all_data)
          all_data = pd.concat([all_data, data])
          all_data.drop_duplicates(subset=&quot;text&quot;, keep=False, inplace=True)
          len_iterated_data = len(all_data)
      else:
          print ('iteration is finished.')
      return data
  </code></pre>
  <p>so, what I would like to happen is this process of combining the new_data and the original data to happen is to process the data until the len of the new_data is no longer larger than the len of the first combination. then the iteration stops
  The problem is that, when I save the length of dataframe, it compares them in the first round and since the length is the same, the iteration never happens. I therefore need to specify the comparison to be made in the next round, not in the first round. so I tried:</p>
  <pre><code>len_iterated_data = next(len(all_data))
  </code></pre>
  <p>but it does not work. is there a way to say next len and not the first one.</p>