LoslegenKostenlos loslegen

Exploring table metadata

After creating the weather data table, the meteorological team needs to understand its structure before generating their reports. The team leader has asked you to provide information about the table's dimensions, columns, and a preview of the data.

The Table, DoubleColumn, and StringColumn classes from Tablesaw have been imported for you.

Diese Übung ist Teil des Kurses

Importing Data in Java

Kurs anzeigen

Anleitung zur Übung

  • Print the table dimensions.
  • Display the column names.
  • Print the table structure.
  • Preview the first three rows.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

public class WeatherMetadataExample {
    public static void main(String[] args) {
        StringColumn days = StringColumn.create("Day", 
            "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
            
        DoubleColumn temperatures = DoubleColumn.create("Temperature", 
            22.5, 24.0, 23.2, 21.5, 20.8, 25.1, 26.3);
            
        DoubleColumn precipitation = DoubleColumn.create("Precipitation", 
            0.0, 2.5, 5.2, 0.0, 0.0, 1.3, 0.0);
        
        Table weatherData = Table.create("WeatherData")
            .addColumns(days, temperatures, precipitation);
        
        // Print the table dimensions
        System.out.println(____.____());
        
        // Display the column names
        System.out.println(____.____());
        
        // Print the table structure
        System.out.println(____.____());
        
        // Preview the first three rows
        System.out.println(____.____(____));

    }
}
Code bearbeiten und ausführen