開始使用免費開始

豐富資料集

.merge() 方法中設定 how='left',是一個能用其他資料表的額外資訊來「豐富」或「擴充」資料集的實用技巧。這題你會從《玩具總動員》(Toy Story)系列的一小部分電影資料開始。你的目標是替每部電影加入行銷宣傳標語,來豐富這份資料。你也會比較左外連接與內連接的結果差異。

toy_story DataFrame 包含《玩具總動員》的電影。toy_storytaglines 兩個 DataFrame 已為你載入。

本練習屬於課程

使用 pandas 進行資料表連接

檢視課程

動手互動練習

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

# Merge the toy_story and taglines tables with a left join
toystory_tag = toy_story.merge(____)

# Print the rows and shape of toystory_tag
print(toystory_tag)
print(toystory_tag.shape)
編輯並執行程式碼