分析數值欄位
你已經在雜貨存貨資料集中找出遺漏值與唯一值。現在,你需要透過分析 Unit_Price 欄位來掌握存貨的定價模式。請計算產品價格的基本統計量:最小值、最大值、平均值,以及標準差。
已為你匯入 tablesaw 套件。
本練習屬於課程
使用 Java 進行資料清理
練習說明
- 取出
Unit_Price欄位。 - 計算
Unit_Price的最小值與最大值。 - 計算
Unit_Price的平均值與標準差。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
public class GroceryDataQuality {
public static void main(String[] args) {
Table inventory = Table.read().csv("grocery_inventory.csv");
// Extract the unit price column
DoubleColumn price = ____.____("Unit_Price");
System.out.println("Stock Quantity Statistics:");
// Compute the min and max of unit price
System.out.println("Min: " + price.____());
System.out.println("Max: " + price.____());
// Compute the mean and standard deviation of the unit price
System.out.println("Mean: " + price.____());
System.out.println("Standard deviation: " + price.____());
}
}