2017-03-17 50 views
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?

+0

您能否讓您的問題更清楚? 你想每天計算s.d嗎? – Himaprasoon

回答

0

我希望你想要的是每個客戶每天的工作時間得到s.d。

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) 
+0

嗨,感謝您的幫助,但我想計算標準偏差的預計時間爲上午9:30。這裏的平均值是上午9:30確定的,然後想要繪製員工標準偏差的K均值 – gopalm