0

我想计算员工每天明智的标准偏差。

以下是我正在导入的数据框或 csv:

EmpCode,Date,InTime,OutTime,expetcedIn,expetcedOut

9889,01-Feb-17,9:34 AM,5:41:00 PM,9:30:00 AM,5:30:00 PM

如何在 Python 中实现它?

4

1 回答 1

0

我希望你想要的是获得每个客户的每日工作时间。

import pandas as pd

# Read csv and parses col[1,2] as InTimeWithDate and col[1,3] as OutTimeWithDate
df=pd.read_csv("emp.csv", parse_dates={"InTimeWithDate":[1,2],"OutTimeWithDate":[1,3]})

# Gets difference between In and out time in minutes : to get in seconds changed timedelta64[m] to timedelta64[s]
df["minutes_worked"]= (df["OutTimeWithDate"]-df["InTimeWithDate"]).astype('timedelta64[m]')

# Groups by employee and gets standard diff of minutes worked
new_df = df.groupby("EmpCode").agg({"minutes_worked":["std"]})
print(new_df)
于 2017-03-17T08:26:37.687 回答