title: targeting values in one column then using the corresponding date stamps to search other columns
body: <p>I have a task to solve as I try to learn Pandas and have previously posted a question <a href="https://stackoverflow.com/questions/59390818/select-rows-based-on-date-before-an-a-column-value-which-is-not-based-on-date">here</a> but now need to adapt this to search for values based on <strong>date</strong>, rather than counting back based on row numbers which @jazrael kindly helped me with.</p>
  
  <p>Basically I have a dataframe like the following: -</p>
  
  <pre><code>id    food     date        mood
  id 1  nuts     2018-11-12  high
  id 2  potatoes 2018-11-13  low
  id 4  bread    2018-11-13  high
  id 5  fish     2018-11-14  high
  id 6  nuts     2018-11-14  high
  id 7  fish     2018-11-15  allergies
  id 8  beer     2018-11-16  low
  id 9  bread    2018-11-17  high
  id 10 fish     2018-11-18  high
  id 11 pasta    2018-11-19  allergies
  </code></pre>
  
  <p>I wish to search on column 'mood' for 'allergies', then using the 'date' value on the row where we found the value 'allergies' to count backwards 2 days and capture all the corresponding food values in the food column (whilst also inc the food items on the row allergies was detected).</p>
  
  <p>So the resulting dataframe could look like the following (<em>I will leave the 'date' and mood' columns in for ease of understanding the question better</em>): -</p>
  
  <pre><code>id    food     date        mood
  id 2  potatoes 2018-11-13  low
  id 3  fish     2018-11-13  high
  id 4  bread    2018-11-13  high
  id 5  fish     2018-11-14  high
  id 6  nuts     2018-11-14  high
  id 7  fish     2018-11-15  allergies
  id 9  bread    2018-11-17  high
  id 10 fish     2018-11-18  high
  id 11 pasta    2018-11-19  allergies
  </code></pre>
  
  <p>Any help much appreciated!</p>
  
  <p>micdoher</p>