員工薪資分析
你正在分析一家科技公司的員工資料。人資部門需要將所有員工的薪資上調 10%。你的任務是轉換每筆薪資,並把結果加入為新欄位。
已匯入 Tablesaw 函式庫,employees.csv 檔案包含 Name、Department、Salary 和 Bonus 欄位。
本練習屬於課程
Java 中的資料匯入
練習說明
- 套用轉換,計算每位員工提高 10% 後的薪資。
- 將新的調整後薪資欄位加入到資料表。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
public class EmployeeSalary {
public static void main(String[] args) {
Table employees = Table.read().csv("employees.csv");
// Apply transformation for 10% increase
DoubleColumn adjustedSalary = employees.intColumn("Salary")
.asDoubleColumn()
.____(salary -> salary * ____);
// Add new column to table
employees.____(adjustedSalary.setName("AdjustedSalary"));
System.out.println("Employee Salary Analysis:");
System.out.println(employees.first(5));
}
}