Answering further questions
Let's say that you are done with the first round of questions that the HR director asked you, but now he wants to know a little more about the employees. The following are the new tasks assigned to you:
- Give me a list of the employees with a Low level of
JobSatisfaction
- Give me a list of the employees with a Low level of both
JobSatisfaction
andJobInvolvement
- Compare the employees with Low and Very High
JobSatisfaction
across the following variables:Age
,Department
, andDistanceFromHome
Employees with Low JobSatisfaction
To answer this question, we use a BooleanSeries to index a series or a DataFrame. This is called masking, or Boolean indexing. First, we use the comparison operator to compare the pandas Series with a data['JobSatisfaction'] == 'Low'
value, as follows:

If you run the operation, you will get a Boolean Series with the values True
orFalse
for each employee. True
is where the value of JobSatisfaction
for an employee is equal to Low and False
is when the...