開始使用免費開始

基本 inner join

比賽進行時的天氣有可能和腦震盪有關。檢視天氣資料後,你發現它只包含 2017 賽季。即便如此,你仍想只針對兩個資料集都有涵蓋的比賽進行合併。

需要使用的資料框 games_placesweather_2017 已經載入。

本練習屬於課程

給試算表使用者的 pandas 合併實務

檢視課程

練習說明

  • 檢視每個資料框的前 5 列。
  • 合併資料,只保留同時存在於兩個資料集的比賽。
  • 檢視資料框的 shape,看看影響為何。

動手互動練習

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

# View data frames
print(____.head())
print(____.head())

# Join data frames
games_weather = games_places.merge(____, on=____, how=____)
games_weather.shape
# View data frame shapes
print(games_places.shape)
print(weather_2017.shape)
print(games_weather.shape)
編輯並執行程式碼