0

I'm trying to create a new dataframe based on existing dataframe's data, I have the following data frame: existing dataframe

And I need to create a new dataframe which sums the amount of workers joined each department every year.

I've tried the following:

emp_dept_sal_s[['dept_name','Year']].groupby(['dept_name','Year']).count()

but the output is: enter image description here

So basically, the question is how do I relative to both columns (dept_name and Year)? Thanks!

Aviv1002
  • 13
  • 4
  • [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – It_is_Chris Dec 21 '22 at 16:26

1 Answers1

0
emp_dept_sal_s.groupby(by=['dept_name','Year']).count()
Alireza75
  • 513
  • 1
  • 4
  • 19