title: How to apply 'groupby' in python if I want to aggregate by sum on a particular column?
body: <p>I have a dataframe that looks like this :
  <a href="https://i.stack.imgur.com/XSyEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSyEJ.png" alt="image of dataframe"></a></p>
  
  <p>I want not repetition in of rows at <code>leid, cp_id, run_seq, prod, curr</code> level and I want to aggregate by sum <code>tran_amnt</code>. I did something like this, but it throws an error.</p>
  
  <pre><code>data_gb = data.groupby('le_id', 'cp_id', 'run_seq', 'products', 'currency').sum()
  </code></pre>
  
  <p>but it throws this error:</p>
  
  <blockquote>
    <p>No axis named cp_id for object type </p>
  </blockquote>
  
  <p>I think this is not working because there are strings present in the dataframe.</p>
  
  <p>Is there any other, better way I can achieve what I want?</p>
  
  <p>Edit:</p>
  
  <p>Here is the code that produces the above dataframe:</p>
  
  <pre><code>import pandas  as pd
  data = {'le_id' : [101]*4 + [102]*4 + [103]*3 + [104]*5 + [101],
          'run_seq' : [31]*11 + [32]*6,
          'cp_id' : [201, 201, 201, 201, 203, 204, 205, 205, 206, 208, 
                    209, 202, 201, 204, 205, 208, 208],
          'cp_name' : ['A', 'A', 'A', 'A', 'B', 'C', 'E', 'E', 'F', 
                     'G', 'H', 'B', 'A', 'D', 'E', 'H', 'H'],
  
          'products' : ['U', 'U', 'U', 'W', 'X', 'U', 'U', 'V', 'W', 
                       'X','U', 'U', 'V', 'W', 'X', 'Z', 'U'],
  
          'tran_amnt' : [10203, 13789, 74378, 47833, 40237, 93732, 
                        63738, 42563, 92822, 11276, 63633, 99292, 27892, 
                        82727, 32442, 55622, 43535],
  
  
          'currency' : ['USD', 'YEN', 'USD', 'SGD', 'USD', 'INR', 'INR', 
                  'SGD', 'USD', 'INR', 'SGD', 'SGD', 'SGD', 'SGD', 
                  'INR', 'INR', 'INR']}
  
           data = pd.DataFrame(data)
  </code></pre>