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.
이 연습은 강의의 일부입니다
Cleaning Data in Java
연습 안내
- Extract the column from
inventoryand count missing values in the column. - Count the
inventoryby unique categories.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
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);
}
}