- Read in the employee data, assign the chosen departments, and import columns to variables:
>>> employee = pd.read_csv('data/employee.csv')>>> depts = ['Houston Police Department-HPD', 'Houston Fire Department (HFD)']>>> select_columns = ['UNIQUE_ID', 'DEPARTMENT', 'GENDER', 'BASE_SALARY']
- Build the query string and execute the method:
>>> qs = "DEPARTMENT in @depts " \ "and GENDER == 'Female' " \ "and 80000 <= BASE_SALARY <= 120000" >>> emp_filtered = employee.query(qs)>>> emp_filtered[select_columns].head()