我有一个数据集需要计数。
Manager hire_request hire_approval hired transfer_request transfer_approval transfer
Adam 0 0 0 0 1 0
Blake 1 0 0 0 0 0
Blake 0 1 0 0 0 0
Blake 1 0 0 0 0 0
Chris 0 0 0 1 0 0
Chris 0 1 0 0 0 0
我需要经理给我一个计数。我试着做df.groupby(['Manager'])['Manager','hire_request','hire_approval', 'hired', 'transfer_request','transfer_approval', 'transfer'].count()
所需输出:
Manager hire_request hire_apporval hire transfer_request transfer_approval transfer
Adam 0 0 0 0 1 0
Blake 2 1 0 0 0 0
Chris 0 1 0 1 0 0
谢谢你
1条答案
按热度按时间qojgxg4l1#
您可以用途:
或者,如果您想聚合所有列,只需用途:
输出: