title: How to filter pandas series values based on a condition
body: <p>I have a pandas series as <code>pd.Series([-1, -1, -1, 0, 0, 0, -5, -5, 0, 0, 0, -1, -1, -1 , -1])</code>. How can I convert it in to <code>pd.Series([-1, 0, 0, 0, -5, -5, 0, 0, 0, -1])</code>.</p>
  
  <p>The condition to filter is that if <code>-1</code>s are more than or equal to <code>3</code> in a streak, then keep the first occurrence and discard the rest. </p>
  
  <p>Since the first <code>-1</code>s streak is <code>3</code>, we keep <code>-1</code> and discard the rest. After the first <code>3</code> values, the streak breaks (since the value is now <code>0</code>). Similarly the last <code>-1</code>s streak is <code>4</code>, so we keep the <code>-1</code> and discard the rest.</p>
  
  <p>The filter only applies to <code>-1</code> and <code>-5</code> should be left as is</p>
  
  <p>Thanks</p>
  
  <p>PS: I thought about groupby, but I think it doesnt honor the <code>streak</code> way that I described above</p>