roclark / sportsipy

A free sports API written for python
MIT License
491 stars 189 forks source link

NCAAF Player dataframes fail for players without a weight listed in sportsreference #141

Closed rlindholm closed 5 years ago

rlindholm commented 5 years ago

Player dataframes are failing for players who don't have a weight listed. For ex. Chris Weinke, https://www.sports-reference.com/cfb/players/chris-weinke-1.html

r = Roster('florida-state', year=2000)
            for player in r.players:
                df = player.dataframe #causes an attribute error

Issue is due to the .replace failing on NoneType objects in .rosters.py. Wrapping it in a

Try: 
    ...
Except (AttributeError): 
    return None

Will likely fix the bug. I'm new to git and wasn't sure which branch to include the fix in since it was pretty minor.

roclark commented 5 years ago

Hey @rlindholm, thanks for the detailed report! You certainly made work a lot easier on my part. :smiley: I was planning on using one of my integer property decorators to handle the weight property to fix this, but you're right, the .replace function would still fail. Wrapping this in the try...except block works like a charm. Already have a fix that's working - just need to create a PR for it and move forwards.

You brought up a good point about git. I haven't made the branch names very clear for this repository, so it probably isn't intuitive how I setup the project for branch names. I will work on updating documentation to hopefully make it clearer. Also, I removed all of my locked branches for each release as the tags should be able to replicate the intended functionality.

Thanks again for the feedback! PR incoming.