title: Find proportion of a variable within each decile of another variable in python
body: <p>I have the below dataset:</p>
  
  <pre><code>HID     Score   Decile_Name Result
  2089    62      4th decile  1
  897     47      2nd decile  0
  85      55      3rd decile  0
  8       74      7th decile  1
  23      31      1st decile  1
  5657    77      8th decile  1
  52      85      9th decile  0
  781     63      6th decile  0
  565     42      1st decile  0
  456     62      4th decile  1
  12      89      10th decile 1
  56      85      9th decile  1
  
  #Create a DataFrame
  df1 = {
       'HID':[2089,897,85,8,23,5657,52,781,565,456,12,56],
      'Score':[62,74,31,77,85,63,42,62,89,85],
      'Decile_Name':['4th decile','7th decile','1st decile','8th decile','9th decile','6th decile','1st decile','4th decile','10th decile','9th decile'],
      'Result' :[1,1,1,1,0,0,0,1,1,1]
  ]}
  
  
  
  df1 = pd.DataFrame(df1,columns=['HID','Score','Decile_Name','Result'])
  </code></pre>
  
  <p>This captures for each student , the Score in a subject and the corresponding Decile of the score. It also captures whether the student has passed or failed(Result)</p>
  
  <p>I want to calculate the proportion of Result = 1 within each Decile(Result %) and overall(in the whole dataset). Expected output:</p>
  
  <pre><code>Attribute Level         Result %    num_of_stu  
  Score - All Categories  0.5         12 # This captures the values for the whole df(df1).
  Score - 1st Decile      0.5         2
  Score - 2nd Decile      0           1
  Score - 3rd Decile      0           1
  ...
  Score - 9th Decile      0.5         2
  Score - 10th Decile     1           1
  </code></pre>
  
  <p>Can someone please help me do this?</p>