title: To find the next from a match of data-frame splits
body: <p>A data frame as below and a list of names.</p>
  <pre><code>['Amelia','Elijah','Amelia']
  </code></pre>
  <p><a href="https://i.stack.imgur.com/jkyEd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jkyEd.png" alt="enter image description here" /></a></p>
  <p>I want to find out, who's the next, when a portion of the data frame matches the given names (the list of names is a fixed sequence). (it's 1990-09-01 00:00:00 James)</p>
  <pre><code>import pandas as pd
  from io import StringIO
  
  to_find_list = ['Amelia','Elijah','Amelia']
  
  short_frame = 3
  
  csvfile = StringIO(
  &quot;&quot;&quot;Date Staff
  1990-05-01 00:00:00 Mason
  1990-06-01 00:00:00 Amelia
  1990-07-01 00:00:00 Elijah
  1990-08-01 00:00:00 Amelia
  1990-09-01 00:00:00 James
  1990-10-01 00:00:00 Benjamin
  1990-11-01 00:00:00 Isabella
  1990-12-01 00:00:00 Lucas
  1991-01-01 00:00:00 Mason&quot;&quot;&quot;)
  
  df = pd.read_csv(csvfile, sep = '\t', engine='python')
  
  # split the df into small frames with overlaps
  list_of_dfs = [df.loc[i:i + short_frame-1,:].reset_index(drop=True) for i in range(0, len(df), short_frame - 2) if i &lt; len(df) - 2]          
  
  for son_df in list_of_dfs:
  
      first_cell = son_df.iloc[0]['Date']
      last_cell = son_df.iloc[-1]['Date']
  
      if son_df['Staff'].to_list() == to_find_list:
          found_date = son_df['Date'].iloc[-1]                # 1990-08-01 00:00:00 
          who = df['Staff'].loc[df['Date'] == found_date]     # Amelia
  </code></pre>
  <p>I've tried to use shift() to print our the next Date and Staff next to &quot;Amelia&quot; but not successful.</p>
  <p>What's the way to achieve it? Thank you.</p>