Skip to content

Instantly share code, notes, and snippets.

@thepycoach
Last active February 10, 2021 00:33
Show Gist options
  • Select an option

  • Save thepycoach/4942f0ba00e12da56df69a02ed392045 to your computer and use it in GitHub Desktop.

Select an option

Save thepycoach/4942f0ba00e12da56df69a02ed392045 to your computer and use it in GitHub Desktop.
#making dataframes for each league scraped (inside the loop)
df_over_under = pd.DataFrame({'Dates':dict_odds['dates_0'], 'Teams':dict_odds['teams_0'], 'over2.5':dict_odds['odds_0']}).set_index(['Teams', 'Dates'])
df_btts = pd.DataFrame({'Dates':dict_odds['dates_1'], 'Teams':dict_odds['teams_1'], 'btts':dict_odds['odds_1']}).set_index(['Teams', 'Dates'])
#concatenating the dataframes previously created for each betting market
df_betfair = pd.concat([df_over_under, df_btts], axis=1, sort=True)
df_betfair.reset_index(inplace=True)
df_betfair.rename(columns={'index':'Teams'}, inplace=True)
#transforming data
df_betfair = df_betfair.fillna('')
df_betfair = df_betfair.replace('SUSPENDED\n', '', regex=True)
df_betfair = df_betfair.applymap(lambda x: x.strip() if isinstance(x, str) else x) #14.0\n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment