Pandas pivot table for multiple columns at once

后端 未结 3 703
无人及你
无人及你 2020-12-05 17:04

Let\'s say I have a DataFrame:

   nj  ptype  wd  wpt
0   2      1   2    1
1   3      2   1    2
2   1      1   3    1
3   2      2   3    3
4   3      1   2         


        
3条回答
  •  日久生厌
    2020-12-05 17:54

    An easier solution is

    employee.pivot_table(index= ‘Title’, values= “Salary”, aggfunc= [np.mean, np.median, min, max, np.std], fill_value=0)
    

    In this case, for the salary column we are using different aggregate functions

提交回复
热议问题