mercredi 28 août 2019

I need to save the output of Print command into a list

I am using pandas to compare time durations to mark attendance. I have used DateTime and timedelta to compare the durations. I want to save the output in the adjacent column so that we know who was present and who was not.

I can compare the values and print if the person was present or absent, but i want to do it in the excel file in front of the name of the person

df1 =df[['Date', 'Agent Name', 'Login Time']]

for x in df1['Login Time']:
s1 = str(x)
s2 = '12:00:00'
s3 = '3:10:00'
s4 = '01:00:00'
FMT = '%H:%M:%S'
tdelta = datetime.strptime(s2, FMT) - datetime.strptime(s1, FMT)
if x == s4:
    print('Aussi')
elif (str(tdelta)) < s3:
    print('Present')
else: 
    print('Check')

what i am thinking is, i will store the value of the output in a list and then add the list to a new column in the df.

Aucun commentaire:

Enregistrer un commentaire