開始使用免費開始

探索資料表中繼資料

建立天氣資料表後,氣象團隊在產出報告前需要先了解其結構。團隊主管請你提供關於資料表的維度、欄位,以及資料預覽等資訊。

已為你匯入 Tablesaw 的 TableDoubleColumnStringColumn 類別。

本練習屬於課程

Java 中的資料匯入

檢視課程

練習說明

  • 列印資料表的維度。
  • 顯示所有欄名。
  • 列印資料表結構。
  • 預覽前 3 列資料。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

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(____.____(____));

    }
}
編輯並執行程式碼