title: How to use groupby and sum
body: <p>I am working on a dataframe where i have to groupby and sum. The way i read is i have to groupby first and select the columns i want to sum. Is there any difference between using groupby first and then selecting the column i want to sum or selecting the column i want to sum first and using the groupby afterwards.</p>
  
  <pre><code>grouped_df = df.groupby('Manager')[['Transaction', 'Defects']].sum()
  
  grouped_df = df[['Transaction','Defects']].groupby('Manager').sum()
  </code></pre>
  
  <p>Is the above code same or can produce different results at times.</p>