开始使用免费开始使用

基础 inner 连接

比赛期间的天气可能与脑震荡有关。查看天气数据后,您发现它只包含 2017 赛季。即便如此,您仍希望只对两个数据集中都覆盖到的比赛进行连接。

相关的数据框 games_placesweather_2017 已加载。

本练习是课程的一部分

面向表格用户的 pandas 连接

查看课程

练习说明

  • 查看每个数据框的前 5 行。
  • 连接数据,只保留两个数据集中同时包含的比赛。
  • 查看数据框的形状,以了解影响。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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)
编辑并运行代码