Department analysis
Your initial analysis impressed the HR team! Now they want to dive deeper into departmental insights. The leadership team is considering budget allocations for next year and needs to understand how salaries are distributed across different departments. They're particularly interested in departments with both high average salaries and a good number of senior employees (age 40+).
The Table, Selection, and aggregate functions (mean, count, max) have been imported for you.
Diese Übung ist Teil des Kurses
Importing Data in Java
Anleitung zur Übung
- Summarize
"Salary"withmean,count, andmax. - Filter for employees aged 40+.
- Sort by
"Department", then"Salary"descending.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
public class DepartmentAnalysis {
public static void main(String[] args) {
try {
Table highEarners = Table.read().csv("top_10_earners.csv");
// Summarize Salary with mean, count, and max
Table salarySummary = highEarners.____("____",
mean, count, max).apply();
System.out.println("Salary Summary:");
System.out.println(salarySummary);
// Filter for employees aged 40+
Table seniorEmployees = highEarners.where(
highEarners.intColumn("____").isGreaterThanOrEqualTo(____));
// Sort by Department, then Salary descending
Table sortedSeniors = seniorEmployees.____("Department")
.sortDescendingOn("Salary");
System.out.println("\nSenior Employees (40+) by Department:");
System.out.println(sortedSeniors);
} catch (Exception e) {
System.err.println("Error reading CSV files: " + e.getMessage());
}
}
}