内连接与返回的行数
到目前为止,您学习的所有合并都是内连接。需要理解的一点是,内连接只返回两个表中键值匹配的行。您将进一步探索这一点:先查看 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)