Inner join 與回傳列數
到目前為止你所學到的所有合併都稱為 inner join。必須理解的是,inner join 只會回傳兩個資料表中鍵值相符的列。你會進一步探究這點:先檢視 wards 與 census 的合併,再與經過些微修改的複本 wards_altered 與 census_altered 的合併相比較。在這些修改後的資料表中,wards 欄的第一列已被更動。你將觀察這對合併造成的影響。這些資料表都已為你載入。
在此練習中,有一點很重要:wards 與 census 資料表一開始各有 50 列。
本練習屬於課程
使用 pandas 進行資料表連接
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Merge the wards and census tables on the ward column
wards_census = wards.merge(____)
# Print the shape of wards_census
print('wards_census table shape:', wards_census.shape)