Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Tue Mar 1 12:30:35 2022
- @author: Sanjit
- """
- import pandas as pd
- allStudDF = pd.read_excel('All_Stud.xlsx', engine='openpyxl')
- gateEntryDF = pd.read_csv('gate_security_person_entry.csv')
- exitList=[]
- entryList=[]
- exitCountList=[]
- entryCountList=[]
- for roll in allStudDF.rollno:
- resDF = gateEntryDF[gateEntryDF.roll == roll]
- if len(resDF)==0:
- exitList.append(None)
- entryList.append(None)
- exitCountList.append(0)
- entryCountList.append(0)
- else:
- resExitDF = resDF[resDF.status_out==1]
- if len(resExitDF)==0:
- exitList.append(None)
- exitCountList.append(0)
- else:
- exitList.append(resExitDF.iloc[0,8])
- exitCountList.append(len(resExitDF))
- resEntryDF = resDF[resDF.status_in==1]
- if len(resEntryDF)==0:
- entryList.append(None)
- entryCountList.append(0)
- else:
- entryList.append(resEntryDF.iloc[0,8])
- entryCountList.append(len(resEntryDF))
- allStudDF['date_first_exit_OUT']=exitList
- allStudDF['date_first_entry_IN']=entryList
- allStudDF['count_exit']=exitCountList
- allStudDF['count_entry']=entryCountList
- # allStudDF['Total Leave']=(allStudDF['date_first_exit_OUT'].apply(pd.to_datetime)-allStudDF['date_first_entry_IN'].apply(pd.to_datetime)).dt.days
- allStudDF.to_csv('All_Stud_updated.csv',index=False)
- # roll='2121EE21'
- # resDF = gateEntryDF[gateEntryDF.roll == roll]
- # if len(resDF)==0:
- # exitList.append(None)
- # entryList.append(None)
- # else:
- # resExitDF = resDF[resDF.status_out==1]
- # if len(resExitDF)==0:
- # exitList.append(None)
- # else:
- # exitList.append(resExitDF.iloc[0,8])
- # resEntryDF = resDF[resDF.status_in==1]
- # if len(resEntryDF)==0:
- # entryList.append(None)
- # else:
- # entryList.append(resEntryDF.iloc[0,8])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement