Advertisement
mayankjoin3

college leave gate security

Jul 28th, 2022
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Mar  1 12:30:35 2022
  4.  
  5. @author: Sanjit
  6. """
  7.  
  8. import pandas as pd
  9.  
  10. allStudDF = pd.read_excel('All_Stud.xlsx', engine='openpyxl')
  11. gateEntryDF = pd.read_csv('gate_security_person_entry.csv')
  12.  
  13. exitList=[]
  14. entryList=[]
  15. exitCountList=[]
  16. entryCountList=[]
  17. for roll in allStudDF.rollno:
  18.     resDF = gateEntryDF[gateEntryDF.roll == roll]
  19.     if len(resDF)==0:
  20.         exitList.append(None)
  21.         entryList.append(None)
  22.         exitCountList.append(0)
  23.         entryCountList.append(0)
  24.     else:
  25.         resExitDF = resDF[resDF.status_out==1]
  26.         if len(resExitDF)==0:
  27.             exitList.append(None)
  28.             exitCountList.append(0)
  29.         else:
  30.             exitList.append(resExitDF.iloc[0,8])
  31.             exitCountList.append(len(resExitDF))
  32.            
  33.         resEntryDF = resDF[resDF.status_in==1]
  34.         if len(resEntryDF)==0:
  35.             entryList.append(None)
  36.             entryCountList.append(0)
  37.         else:
  38.             entryList.append(resEntryDF.iloc[0,8])
  39.             entryCountList.append(len(resEntryDF))
  40.  
  41. allStudDF['date_first_exit_OUT']=exitList
  42. allStudDF['date_first_entry_IN']=entryList
  43. allStudDF['count_exit']=exitCountList
  44. allStudDF['count_entry']=entryCountList
  45.  
  46. # allStudDF['Total Leave']=(allStudDF['date_first_exit_OUT'].apply(pd.to_datetime)-allStudDF['date_first_entry_IN'].apply(pd.to_datetime)).dt.days
  47. allStudDF.to_csv('All_Stud_updated.csv',index=False)
  48.  
  49. # roll='2121EE21'
  50. # resDF = gateEntryDF[gateEntryDF.roll == roll]
  51. # if len(resDF)==0:
  52. #     exitList.append(None)
  53. #     entryList.append(None)
  54. # else:
  55. #     resExitDF = resDF[resDF.status_out==1]
  56. #     if len(resExitDF)==0:
  57. #         exitList.append(None)
  58. #     else:
  59. #         exitList.append(resExitDF.iloc[0,8])
  60.        
  61. #     resEntryDF = resDF[resDF.status_in==1]
  62. #     if len(resEntryDF)==0:
  63. #         entryList.append(None)
  64. #     else:
  65. #         entryList.append(resEntryDF.iloc[0,8])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement