開始使用免費開始

加入旗標欄位

另一個團隊已經為每筆房源建立了旗標欄位:價格帶分類,以及評論關注旗標。這些欄位存在名為 tags 的另一個 DataFrame 中,且與 hotels 對齊。你需要把這些欄位加到 hotels,讓它們能並排顯示。

polars 已載入為 pl。DataFrame hotelstags 已預先載入供你使用。

本練習屬於課程

使用 Polars 進行資料轉換

檢視課程

練習說明

  • hotelstags 並排合併為新的 DataFrame,命名為 hotels_with_flags
  • 列印幾列資料,確認新欄位已加入。

動手互動練習

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

# Combine hotels and tags horizontally
hotels_with_flags = pl.concat([____, ____], how="____")

# Print a few rows
print(hotels_with_flags.____())
編輯並執行程式碼