Concatenating rows
You and the team are ready to continue the project to reduce player concussions in the NFL. Previously you looked at game data from the 2016 and 2017 seasons and determined that the data should be joined. Among other things, it will help you to compare the number of games for each season by season type.
Data from both seasons have been loaded into two data frames, games_2016
and games_2017
. Please assume for this exercise and all remaining exercises, that pandas
has been imported as pd
.
This exercise is part of the course
Pandas Joins for Spreadsheet Users
Exercise instructions
- View each data frame to refresh your memory.
- Concatenate the data frames by consecutive season.
- Cross-tabulate
Season
andSeasonType
withpd.crosstab()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# View 2016 and 2017 games
print(____)
____(games_2017)
# Concatenate data frames
games = ____([____, ____])
# Cross-tabulate Season and Season Type
print(pd.crosstab(games.Season, games.SeasonType))