RamParameswaran / pyAFL

Python AFL (Australian Football League) library for collecting/analysing AFL data from AFLtables.com
MIT License
16 stars 10 forks source link

Player Bio #8

Open audas opened 3 years ago

audas commented 3 years ago

Not really sure how to go about making changes - but it would be great if we could get player stats to include player bio so we can have their date of birth etc. If we get it as a timestamp then we can also use it as useable data, same for height and weight. Something like this? Sorry if this is not the way of going about things.

`

  player_bio={}
    for i in soup.find_all('b'):
        if(re.sub(r"[\n\t\s]*", "", i.get_text())=="Born:"):
            player_bio["dob"]=re.sub(r"[\n\t\s]*", "", i.next_sibling.replace(" (",""))    
            timestamp = (datetime.strptime(player_bio["dob"], '%d-%b-%Y') - datetime(1970, 1, 1)).total_seconds()
            player_bio["timestamp"]=timestamp
        if(re.sub(r"[\n\t\s]*", "", i.get_text())=="Height:"):
            player_bio["height"]=re.sub("[^0-9]", "",i.next_sibling)
        if(re.sub(r"[\n\t\s]*", "", i.get_text())=="Weight:"):
            player_bio["weight"]=re.sub("[^0-9]", "",i.next_sibling) `
RamParameswaran commented 3 years ago

Thanks @audas. Great idea! And this is definitely how to go about making changes! Much appreciated :smile:

Perhaps we can add a 'metadata' attribute to the Player object which contains these data fields. For example, see Stuart Magee:

player.metadata = {"height": 174, 
                   "weight": 74, 
                   "born": <timestamp_object: "13-Oct-1943">,
                   "debut": <timestamp_object: "01-Oct-1958">, 
                   "last": <timestamp_object: "01-Oct-1968">, 
                   }

@audas would you like to implement this patch? You've already written most of the HTML parsing, now just need to plug it into the Player.get_player_stats() function. I'd be happy to help out if you're unsure about how to contribute!

RamParameswaran commented 3 years ago

On immediate second thought - perhaps it's better to make that data available as a Pandas dataframe, like all the other data... @audas what do you think?

audas commented 3 years ago

I added what you have done yes. It comes back in the form of player_bio as part of the object. I also added a new function called get_player_bio() which returns ONLY this so it can be used as a faster function.

I have placed all of Carlton so far into a local database for faster cross reference..

RamParameswaran commented 3 years ago

Sounds great @audas. Would you be able to push your update to Github?

audas commented 3 years ago

I am not confident on doing this sort of thing RamParameswaran - I can post my code, but I feel very uncertain on doing things like this. I would like to learn and try.

I download things as a zip file and work on them in Eclipse or InteliJ etc.

RamParameswaran commented 3 years ago

That's 100% okay @audas! pyAFL is a fun hobby project, and a really good way learn about Open Source :wink:

Here's a great video that explains the basics of using Github and contributing to open source projects.

AntonySJohn commented 3 years ago

@RamParameswaran Hey, is this still up for grabs? I'd like to try working on it.

RamParameswaran commented 3 years ago

Hi @AntonySJohn yep this is still up for grabs. I'd be happy to help or advise if you need, just ping me.

adrperez5 commented 7 months ago

Hi @RamParameswaran, is this still up for grabs? I would like to give it a try.

RamParameswaran commented 7 months ago

Hi @adrperez5. Yep no-one else has picked this up, so it is definitely up for grabs! I'm happy for you to implement this as you think best. And I'll of course review and merge your PR promptly. Thanks!

adrperez5 commented 7 months ago

Hi @audas I have placed the bio information in the Player object as an attribute so it may be called using player.metadata after calling get_player_stats. player.metadata is currently a dictionary. This is my first time contributing, so I would like some guidance on how to have my code reviewed.