시작하기무료로 시작하기

부서 분석

초기 분석이 HR 팀에 깊은 인상을 주었어요! 이제 부서별 인사이트를 더 자세히 보고 싶어 합니다. 경영진은 내년 예산 배정을 검토 중이며, 부서별 급여가 어떻게 분포되어 있는지 파악해야 해요. 특히 평균 급여가 높고 시니어 직원(40세 이상)이 충분히 있는 부서에 관심이 많아요.

Table, Selection, 그리고 집계 함수(mean, count, max)는 미리 임포트되어 있어요.

이 연습은 강의의 일부입니다

Java에서 데이터 가져오기

강의 보기

연습 안내

  • "Salary"mean, count, max로 요약하세요.
  • 40세 이상 직원만 필터링하세요.
  • "Department"로 정렬한 뒤, "Salary"는 내림차순으로 정렬하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

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());
        }
    }
}
코드 편집 및 실행