SELECT AVG(salary) AS Avg_salary_of_manager
FROM employee
WHERE job_desc = 'Manager';
EVALUATE
SUMMARIZECOLUMNS (
"Avg_salary_of_manager",
CALCULATE (
AVERAGE(employee[salary]),
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'],
'salary': [70000, 50000, 80000, 60000, 75000]
}
df = pd.DataFrame(data)
# Calculate the average salary of managers
avg_salary_of_manager = df[df['job_desc'] == 'Manager']['salary'].mean()
# Result in list of lists
result = [['Avg_salary_of_manager', avg_salary_of_manager]]
print(result)
| Avg_salary_of_manager | 75000 |
CALCULATE(AVERAGE(employee[salary]), employee[job_desc] = "Manager"): This calculates the average salary from the employee table where the job_desc column is equal to 'Manager'. SUMMARIZECOLUMNS: Creates a table with a single column named Avg_salary_of_manager that contains the average salary of managers.
Leave a Comment