This is the only place I know where I can leave a note-to-self quickly.
import pandas as pd
from cfbd import AP_TOP_25
# Retrieve the AP Top 25 college football standings
standings = AP_TOP_25()
# Create empty lists to store the data
teams = []
votes = []
conferences = []
# Iterate through the standings and extract the required information
for team in standings:
teams.append(team.team.full_name)
votes.append(team.votes)
conferences.append(team.team.conference)
# Create a pandas dataframe using the collected data
df = pd.DataFrame({'Team': teams, 'Votes': votes, 'Conference': conferences})
# Print the dataframe
print(df)
Make sure you have the cfbd
package installed (pip install cfbd
) before running the code. The code utilizes the AP_TOP_25()
function from cfbd to retrieve the AP Top 25 standings. It then iterates through the standings, extracts the team name, votes received, and conference for each team, and stores them in separate lists. Finally, it creates a pandas dataframe using the collected data and prints the resulting dataframe.
Please note that the cfbd
package relies on external APIs and the availability of data. Ensure you have an active internet connection to retrieve the latest standings.