title: relation between two columns Python
body: <p>I'm trying to work out how to determine a relationship between two columns in a dataframe. The relation is between Items and Total. I want to work out the sum Total amount for each 'Items' value, where Items are the number of items per basket and Total is the total amount/cost per basket. The columns:</p>
  
  <pre><code>    Date   Time    Basket   Items   Total
  </code></pre>
  
  <p>My current Python code to get each frequency of the number of items is: </p>
  
  <pre><code>items  = result['Items'].value_counts()
  </code></pre>
  
  <p>I've tried this code to get the totals (and others..):</p>
  
  <pre><code>Total_per_Items = result.groupby(['Items','Total'])
  Totals = Total_per_Items['Total'].sum()
  Totals
  </code></pre>
  
  <p>and get this output:</p>
  
  <pre><code>Items  Total 
  1  0.00        0.00
     0.01        0.03
     0.02        0.02
     0.11        0.11
     0.22        0.22
     0.24        0.24
     0.28        0.28
     0.29        0.29
  </code></pre>
  
  <p>Where instead I want to get something like:</p>
  
  <pre><code>Items    Total
  1        10500.65
  2        2300.50
  3        3450.34
  </code></pre>
  
  <p>I made up the output above but I'm sure you get the drift. It's got me baked.</p>