BaşlayınÜcretsiz Başlayın

Aggregating columns

You need to clean and analyze your stock data to understand high-value inventory patterns. Raw inventory data often includes irrelevant items and needs organization by category. Clean the data by filtering for expensive items (over $5), then calculate accurate totals, and organize by category. This cleaned and summarized view helps identify which departments have the most investment in premium products.

tablesaw packages have been imported for you.

Bu egzersiz

Cleaning Data in Java

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Find expensive items (Unit_Price > $5.00).
  • Calculate the total Stock_Quantity for each category.
  • Group results by Category.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

public class GroceryDataAggregation {
    public static void main(String[] args) {
        Table inventory = Table.read().csv("grocery_inventory.csv");

        Table quantityByCategory = inventory
                // Find expensive items (price > $5.00)
                .where(inventory.doubleColumn("Unit_Price").____(5.0))
                // Calculate total stock for each category
                .____("Stock_Quantity", ____)
                // Group results by product category
                .____("Category");

        System.out.println("Total quantity by category:");
        System.out.println(quantityByCategory.first(5));
    }
}
Kodu Düzenle ve Çalıştır