CodePudding user response:
You can use ~
operator to negate a condition, so:
df[~df.EmployeeLeaveTaken]
will print out the rows where EmployeeLeaveTaken
is False.
CodePudding user response:
To filter on the True values you can do something like this:
only_true= df.loc[df['EmployeeLeaveTaken']==True]
In case you want to do something on each record instead you could also just do a for loop as you said and one by one perform an action if the employee has taken a leave:
for i in range(len(df)):
if df.loc[i, "EmployeeLeaveTaken"] == True:
print(df.loc[i])
# Do something
As you can see in both instances loc[...]
allows you to select the records based on index.