開始使用免費開始

合併取得戲院所在地

嗨!現在我們沒有戲院的所在地,只有戲院名稱。不過,如果兩者都要呢?

目前已載入兩個 DataFrame:

  • theater_sales:依戲院名稱彙總的售出票數。
  • theater_info:列出戲院名稱與各戲院所在地的表格。

你可以在主控台查看它們,幫助你更了解這些資料。

它們都有關聯鍵欄位,但欄位名稱不相同。我們就在這個練習中處理這個合併吧!

本練習屬於課程

給試算表使用者的 Python

檢視課程

練習說明

  • theater_sales 上使用 .merge() 方法,根據正確的鍵欄位與 theater_info 進行合併。
  • 使用 .drop() 方法,從 sales_join 中移除多餘的 theater 欄。

動手互動練習

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

# Join the tables
sales_join = ____

# Drop the redundant theater column
sales_complete = ____

# Print the table
print(sales_complete)
編輯並執行程式碼