開始使用免費開始

建立表格

紐約的一個在地氣象站需要在異常熱浪期間,追蹤一週報告所用的每日溫度讀數。站務主管請你建立一個簡單的資料結構,之後可用來為每週的氣候簡報產生統計與視覺化。這個表格應協助氣象學家辨識溫度與降水型態中的趨勢與異常。

已為你匯入 Tablesaw 的 TableDoubleColumnStringColumn 類別。

本練習屬於課程

Java 中的資料匯入

檢視課程

練習說明

  • 建立 3 個欄位:星期幾、溫度、降水量。
  • 建立一個表格,並將所有欄位加入其中。

動手互動練習

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

public class WeatherTableExample {
    public static void main(String[] args) {
        // Create three columns
        StringColumn days = ____.____("Day", 
            "Monday", "Tuesday", "Wednesday");
            
        DoubleColumn temperatures = ____.create("Temperature", 
            22.5, 24.0, 23.2);
            
        DoubleColumn precipitation = ____.create("Precipitation", 
            0.0, 2.5, 5.2);
        
        // Create a table and add all columns
        Table weatherData = Table.____("WeatherData")
            .____(____, ____, precipitation);
        
        System.out.println(weatherData);
    }
}
編輯並執行程式碼