欠損値と一意の値の分析
あなたは食料品の在庫アナリストとして、新しい在庫管理システムのデータ品質を評価する必要があります。在庫量や価格を分析する前に、欠損データの確認と商品カテゴリの検証を行いましょう。在庫データを読み込み、各列の完全性を確認した上で、カテゴリの分布を分析します。サンプルデータを以下に示します。
| Product_Name | Category | Date_Received | Stock_Quantity | Unit_Price |
|---|---|---|---|---|
| Bell Pepper | Fruits & Vegetables | 3/1/24 | 46 | 4.6 |
| Vegetable Oil | Oils & Fats | 4/1/24 | 51 | 2 |
| Parmesan Cheese | Dairy | 4/1/24 | 38 | 12 |
tablesaw パッケージはあらかじめインポートされています。
この演習はコースの一部です
Java によるデータクリーニング
演習の手順
inventoryから列を取り出し、その列の欠損値の数を数えましょう。inventoryを一意のカテゴリごとに集計しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
public class GroceryDataQuality {
public static void main(String[] args) {
Table inventory = Table.read().csv("grocery_inventory.csv");
for (String colName : inventory.columnNames()) {
// Extract the column and count missing values in the column
int missing = inventory.____(colName).____();
System.out.println(colName + " missing values: " + missing);
}
// Count the inventory by unique categories
Table catCounts = ____.____("Category");
System.out.println("\nCategory distribution:");
System.out.println(catCounts);
}
}