0

I want to calculate the standard deviation for the employee wise daily time.

following is the data frame or csv I am importing:

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

How go about it in Python?

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
gopalm
  • 1

1 Answers1

0

I hope what you want is get s.d of daily working time for each customer.

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)
Himaprasoon
  • 2,609
  • 3
  • 25
  • 46
  • Hi, thanks for the help but I want to calculate the Standard deviation from the expected in time that is 9:30 AM. here the mean is fixed that 9:30 AM and then want to Plot the K-mean for the employee's standard deviation – gopalm Mar 18 '17 at 04:57