import plotly.express as px
import plotly.graph_objects as go
import pandas as pd
df = pd.read_excel ('the sample sheet i have attached')
indexNames = df[ (df['counter'] != -1) & (df['counter'] != 1) & (df['id'] >= "Fri Jul 10 19:33:12 GMT+05:30 2020") ].index
dff.drop(indexNames , inplace=True)
v = df.employee_id.value_counts()
new_df= df[df.employee_id.isin(v.index[v.eq(1)])]
new_df
I wanted new_df data frame to only have data of the employee who have login but not log out. In attached excel data sheet if counter = -1 then i am assuming logout and if counter = 1 i am assuming login link for the sheet "https://drive.google.com/file/d/1E9hivsHzc9lc_IQG0mWf36fc8F4HgPDm/view?usp=sharing"
I don't have the filter for the time, but here's a way to get the records for employees that don't have a counter record = -1
import pandas as pd
logins = {'EmployeeId': [22, 22, 22, 22, 67, 67, 67],
'Counter': [1, 2, 3, -1, 1, 2, 3] }
df = pd.DataFrame(logins)
df2 = df.loc[df['Counter'] == -1]
print(df[~df['EmployeeId'].isin(df2['EmployeeId'])])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.