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 |
Este exercício faz parte do curso
Cleaning Data in Java
Instruções do exercício
- Extract the column from
inventory
and count missing values in the column. - Count the
inventory
by unique categories.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
import tech.tablesaw.api.Table;
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);
}
}