import pandas as pd
import numpy as np
data_agency = pd.read_excel("Sample.xlsm")
data_agency.groupby(['Person']).sum()
type(data_agency['Person'].iloc[0])
返回str
类型
type(data_agency['Reg Hrs.'].iloc[0])
返回float64
类型
答案 0 :(得分:0)
您可以选择那些列,然后应用聚合
data_agency.groupby(['Person'])[["LunchBreak", "HoursWorked", "Regofhours","RegNSDHrs","RegOTNSDHRS"]].sum()
答案 1 :(得分:0)
data_agency.groupby('Person').agg('sum')