I have been using groupybe()
to see how many each employee has done projects. It works fine but I would like to extract the employee_id column too, but i can not use it:
when I do n_project[0]
I get only the first value without the id. Any ideas on how do I fix that problem?
CodePudding user response:
The .groupby()
function takes a column or columns and sets as the index of the output DataFrame by default. If that's not the desired output, try adding the as_index = False
argument into the groupby function. Documentation here.
n_project = df_projects.groupby('employee_id', as_index=False)['project_id'].count()