Skip to content

Instantly share code, notes, and snippets.

@thepycoach
Last active February 11, 2021 18:51
Show Gist options
  • Select an option

  • Save thepycoach/9e68c109ff143714e41ba40fa667b71d to your computer and use it in GitHub Desktop.

Select an option

Save thepycoach/9e68c109ff143714e41ba40fa667b71d to your computer and use it in GitHub Desktop.
#pickle data scraped in section 1
dict_betfair = pickle.load(open('dict_betfair', 'rb'))
#initialize storage (we'll use these dictionaries to match names between betfair and historical_data)
dict_home_name_matching = {}
dict_away_name_matching = {}
#fill the dictionary with a list of names of all home and away teams that will play during the week
for league in dict_betfair:
dict_betfair[league][['home_team', 'away_team']] = dict_betfair[league]['Teams'].str.extract(r'(.+)\n(.+)')
dict_home_name_matching[league] = dict_betfair[league].groupby('home_team', as_index=False).count()[['home_team']]
dict_away_name_matching[league] = dict_betfair[league].groupby('away_team', as_index=False).count()[['away_team']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment