เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การทำความสะอาดและปรับปรุงข้อมูล

TechCorp กำลังย้ายไปใช้ระบบ HR ใหม่ ชุดข้อมูลจำเป็นต้องได้รับการทำความสะอาด ได้แก่ ลบค่าผิดปกติด้านเงินเดือนที่เกิดจากความผิดพลาดในการป้อนข้อมูล ลบคอลัมน์ที่ระบบใหม่ไม่ต้องการใช้ และเพิ่มฟิลด์โบนัสที่คำนวณแล้ว การทำความสะอาดข้อมูลมักใช้เวลาถึง 80% ของกระบวนการวิเคราะห์ ทักษะเหล่านี้จึงสำคัญมาก

คลาส Table, Selection และ DoubleColumn ได้ถูก import ไว้ให้แล้ว

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

การนำเข้าข้อมูลใน 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));
	}
}
แก้ไขและรันโค้ด