title: mean of a column based on the index and another 2 columns
body: <p>I have this dataframe:</p>
  <pre><code>d = {'day': [0,0,0,0,0,0, 1,1,1,1,1,1, 2,2,2,2,2,2], 'period': ['p1','p1','op1','op1','p2','p2','p1','p1','op1','op1','p2','p2','p1','p1','op1','op1','p2','p2'], 's1':[2,2,3,6,4,2,8,2,1,2,1,2,2,9,5,2,2,3]}  
  df = pd.DataFrame(data=d)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/GU3ph.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GU3ph.png" alt="enter image description here" /></a></p>
  <p>And i need this result:</p>
  <p><a href="https://i.stack.imgur.com/0lg7q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0lg7q.png" alt="enter image description here" /></a></p>
  <p>I tried this:</p>
  <pre><code>df.groupby('period', as_index=False)['s1'].mean()
  </code></pre>
  <p>Here is its result:</p>
  <p><a href="https://i.stack.imgur.com/vxrAX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vxrAX.png" alt="enter image description here" /></a></p>
  <p>But it doesn't solve my problem..</p>