员工明智的日常出勤时间标准差

时间:2017-03-17 04:54:16

标签: python-3.x standards deviation

我想计算员工明智日常时间的标准差。

以下是我导入的数据框或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中实现它?

1 个答案:

答案 0 :(得分: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)