데이터 정제와 향상
TechCorp가 새로운 HR 시스템으로 마이그레이션하고 있어요. 데이터셋을 정제해야 합니다. 입력 오류로 보이는 저임금 이상치를 제거하고, 새 시스템에서 사용하지 않는 열을 삭제하며, 계산된 보너스 필드를 추가하세요. 데이터 정제는 보통 전체 분석 시간의 80%를 차지합니다. 이 기술은 필수예요.
Table, Selection, 그리고 DoubleColumn 클래스는 미리 임포트되어 있습니다.
이 연습은 강의의 일부입니다
Java에서 데이터 가져오기
연습 안내
- 연봉이 $40,000 미만인 직원들을 제거하세요.
"JobTitle"열을 제거하세요.PerformanceBonus열(연봉의 5%)을 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
public class DataExploration {
public static void main(String[] args) {
Table employees = Table.read().csv("employees.csv");
// Remove employees with salaries below $40,000
Selection lowSalaries = employees.intColumn("Salary").isLessThan(____);
Table cleanedEmployees = employees.____(lowSalaries);
// Remove the JobTitle column
Table streamlined = cleanedEmployees.____("JobTitle");
DoubleColumn performanceBonus = streamlined.intColumn("Salary").asDoubleColumn()
.map(salary -> salary * 0.05);
performanceBonus.setName("PerformanceBonus");
// Add the PerformanceBonus column
Table enhancedEmployees = streamlined.____(performanceBonus);
System.out.println("Total employees after cleaning: " + enhancedEmployees.rowCount());
System.out.println("\nFirst 5 rows of enhanced dataset:");
System.out.println(enhancedEmployees.first(5));
}
}