SELECT COUNT(*) AS Count_of_manager
FROM employee
WHERE job_desc = 'Manager';
EVALUATE
SUMMARIZECOLUMNS (
"Count_of_manager",
CALCULATE (
COUNTROWS ( employee ),
employee[job_desc] = "Manager"
)
)
import pandas as pd
# Sample DataFrame
data = {
'employee_id': [1, 2, 3, 4, 5],
'job_desc': ['Manager', 'Clerk', 'Manager', 'Analyst', 'Manager']
}
df = pd.DataFrame(data)
# Count the number of managers
count_of_manager = df[df['job_desc'] == 'Manager'].shape[0]
# Result in list of lists
result = [['Count_of_manager', count_of_manager]]
print(result)
| Count_of_manager | 3 |
CALCULATE(COUNTROWS(employee), employee[job_desc] = "Manager"): This calculates the number of rows in the employee table where the job_desc column is equal to 'Manager'. SUMMARIZECOLUMNS: Creates a table with a single column named Count_of_manager that contains the count of managers.
Leave a Comment