Analyzing missing and unique values
As a grocery inventory analyst, you need to assess data quality in your new inventory tracking system. Before analyzing stock levels and pricing, you need to check for missing data and verify product categorization. Load the inventory data, examine each column for completeness, and analyze category distributions. Some sample data is shown below.
| 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 packages have been imported for you.
Cet exercice fait partie du cours
Cleaning Data in Java
Instructions
- Extract the column from
inventoryand count missing values in the column. - Count the
inventoryby unique categories.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
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);
}
}