title: cumsum with average - python
body: <p>I have a pd.DataFrame like below,</p>
  
  <pre><code>Hr    Name       Count       Day
  6    1318       10.0        Friday     
  7    1318       20.0        Friday     
  8    1318       2.0         Friday     
  9    1318       18.0        Friday        
  6    1318       2.0         Monday
  7    1318       15.0        Monday
  8    1318       2.0         Monday
  9    1318       5.0         Monday
  6    1319       20.0        Friday     
  7    1319       30.0        Friday     
  8    1319       50.0        Friday     
  9    1319       5.0         Friday     
  6    1319       3.0         Monday
  7    1319       30.0        Monday
  8    1319       2.0         Monday
  9    1319       5.0         Monday
  </code></pre>
  
  <p>I want to iterate each <strong>Count</strong> and sum Name wise, then make 1 if the value is >=20. finally count the values how many times reached above >=20.
  When sum of Count reached >=20 then next value should be counted with actual value.</p>
  
  <p>Expected OP :</p>
  
  <pre><code>[{'Friday' :[2,3],'Monday':[1,1]}]
  </code></pre>
  
  <p>Here is How to Do for Friday:</p>
  
  <pre><code>1318Friday[10+20=30 30 &gt;=20 so 1, 2+18 =20 again 1, Total is 2]
  1319Friday[20 20 &gt;=20 so 1, 30 again 1,50 again 1,5 is !&gt;=20, Total is 3]
  Finally {'Friday' : [2,3]}
  </code></pre>
  
  <p>Code I have tried :</p>
  
  <pre><code>finalresult = [data]
  df = pd.DataFrame(finalresult)
  df['csum'] = df.groupby(['Day','Name'])['Count'].cumsum()
  </code></pre>