Created
February 6, 2021 17:53
-
-
Save thepycoach/3875e5bc8c43ee5c4f526761c7ebd8a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dict_leagues = {'Spanish La Liga':'SP1', 'German Bundesliga':'D1', | |
| 'English Premier League':'E0', 'Italian Serie A':'I1'} | |
| dict_historical_data = {} | |
| for league in dict_leagues: | |
| frames = [] | |
| for i in range(15, 21): | |
| df = pd.read_csv("http://www.football-data.co.uk/mmz4281/"+str(i)+str(i+1)+"/"+dict_leagues[league]+".csv") | |
| df = df[['Date', 'HomeTeam', 'AwayTeam', 'FTHG', 'FTAG']] | |
| df = df.rename(columns={'HomeTeam':'home_team', 'AwayTeam':'away_team','FTHG': 'home_goals', 'FTAG': 'away_goals'}) | |
| df = df.assign(season=i) | |
| frames.append(df) | |
| df_historical_data = pd.concat(frames) | |
| dict_historical_data[league] = df_historical_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment