Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove (rather fix) accents in injury reports #74

Open
germannp opened this issue Mar 3, 2022 · 0 comments
Open

Remove (rather fix) accents in injury reports #74

germannp opened this issue Mar 3, 2022 · 0 comments

Comments

@germannp
Copy link

germannp commented Mar 3, 2022

Hello,

In box reports player's names with accents are fixed using utils.remove_accents, I guess the same should be done for injury reports. This could in principle be easily done, like

def get_injury_report():
    r = get(f'https://widgets.sports-reference.com/wg.fcgi?css=1&site=bbr&url=%2Ffriv%2Finjuries.fcgi&div=div_injuries')
    if r.status_code==200:
        soup = BeautifulSoup(r.content, 'html.parser')
        table = soup.find('table')
        df = pd.read_html(str(table))[0]
        df.rename(columns = {'Player': 'PLAYER', 'Team': 'TEAM', 'Update': 'DATE', 'Description': 'DESCRIPTION'}, inplace=True)
        df['TEAM'] = df['TEAM'].apply(lambda x: TEAM_TO_TEAM_ABBR[x.upper()])
        df['DATE'] = df['DATE'].apply(lambda x: pd.to_datetime(x))
        df['PLAYER'] = df.apply(lambda injury: remove_accents(injury.PLAYER, injury.TEAM, df['DATE'].max().year, axis=1)
        df['STATUS'] = df['DESCRIPTION'].apply(lambda x: x[:x.index('(')].strip())
        df['INJURY'] = df['DESCRIPTION'].apply(lambda x: x[x.index('(')+1:x.index(')')].strip())
        df['DESCRIPTION'] = df['DESCRIPTION'].apply(lambda x: x[x.index('-')+2:].strip())
        return df

However, I fear that might fail e.g. if someone got traded and there was no injury yet in the new year or so. What do you think?

Cheers :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant