LoslegenKostenlos starten

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.

Diese Übung ist Teil des Kurses

<Kurs>Cleaning Data in Java</Kurs>
Kurs ansehen

Übungsanweisungen

  • Extract the column from inventory and count missing values in the column.
  • Count the inventory by unique categories.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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);
    }
}
Code bearbeiten und ausführen