串接文字欄位
清掉多餘空白後,你發現有些產品的說明相同,但尺寸不同。為了唯一識別每個產品款式,你需要把 detail 和 size 這兩個欄位合併成單一識別碼。
本練習屬於課程
使用 Polars 進行資料轉換
練習說明
- 使用「冒號」作為分隔符,將
detail與size兩個欄位串接,並將新欄位命名為detail_size。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Combine detail and size into a new column
reviews.with_columns(
pl.____(["detail", "size"], separator="____").____("detail_size")
)