title: How I can aggregate employee based on their department and show average salary in each department using groupby pandas?
body: <p>This is my code which has data in which I want to perform the task using <strong>pandas.DataFrame.groupby</strong></p>
  <pre><code>import pandas as pd
  data = {'employees_no':  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
          'employees_name': ['Jugal Sompura', 'Maya Rajput', 'Chaitya Panchal', 'Sweta Rampariya', 'Prakshal Patel', 'Dhruv Panchal', 'Prachi Desai', 'Krunal Gosai', 'Hemil Soni', 'Gopal Pithadia', 'Jatin Shah', 'Raj Patel', 'Shreya Desai'],
          'department_name': ['HR', 'Administrative Assistant', 'Production', 'Accountant', 'Production', 'Engineer', 'Finance', 'Engineer', 'Quality Assurance', 'Engineer', 'Engineer', 'Customer Service', 'CEO'],
          'salary': [130000.0, 65000.0, 45000.0, 65000.0, 47000.0, 40000.0, 90000.0, 45000.0, 35000.0, 45000.0, 30000.0, 40000.0, 250000.0]
          }
  </code></pre>
  <pre><code>df = pd.DataFrame (data, columns = ['employees_no', 'employees_name', 'department_name', 'salary'])
  print(df)
  ---------------------------------------------------------------------
  employees_no   employees_name           department_name      salary
  0              1    Jugal Sompura                        HR  130000.0
  1              2      Maya Rajput  Administrative Assistant   65000.0
  2              3  Chaitya Panchal                Production   45000.0
  3              4  Sweta Rampariya                Accountant   65000.0
  4              5   Prakshal Patel                Production   47000.0
  5              6    Dhruv Panchal                  Engineer   40000.0
  6              7     Prachi Desai                   Finance   90000.0
  7              8     Krunal Gosai                  Engineer   45000.0
  8              9       Hemil Soni         Quality Assurance   35000.0
  9             10   Gopal Pithadia                  Engineer   45000.0
  10            11       Jatin Shah                  Engineer   30000.0
  11            12        Raj Patel          Customer Service   40000.0
  12            13     Shreya Desai                       CEO  250000.0
  ---------------------------------------------------------------------
  </code></pre>
  <p>I tried this and could only get this output.</p>
  <pre><code>print(df.groupby('department_name').agg({'salary':'mean'}))
  ---------------------------------------------------------------------
  department_name             salary
  Accountant                 65000.0
  Administrative Assistant   65000.0
  CEO                       250000.0
  Customer Service           40000.0
  Engineer                   40000.0
  Finance                    90000.0
  HR                        130000.0
  Production                 46000.0
  Quality Assurance          35000.0
  ---------------------------------------------------------------------
  </code></pre>
  <p>I'm not able to get output like this...</p>
  <pre><code>department_name          employees_name     avg_salary        
  Accountant               Sweta Rampariya     65000.0
  Administrative Assistant Maya Rajput         65000.0
  CEO                      Shreya Desai       250000.0
  Customer Service         Raj Patel           40000.0
  Engineer                 Dhruv Panchal       40000.0
                           Gopal Pithadia      
                           Krunal Gosai        
                           Jatin Shah     
  Finance                  Prachi Desai        90000.0
  HR                       Jugal Sompura      130000.0
  Production               Chaitya Panchal     46000.0
                           Prakshal Patel      
  Quality Assurance        Hemil Soni          35000.0
  </code></pre>
  <p>Can you help me with this?</p>