Giter Site home page Giter Site logo

Comments (13)

joshbis avatar joshbis commented on May 22, 2024 2

thanks -- here's my week one masterpiece. looking forward to playing around with it more over the course of the season.

https://www.dropbox.com/s/u0zg32qze4zue1c/w1_payoffs.png?dl=0

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024 1

Check out the league function load_roster_week(week=1). That should set the Teams roster to that week. I havenโ€™t tried it for this season yet because week 1 just ended but I believe that is what you are looking for.

from espn-api.

joshbis avatar joshbis commented on May 22, 2024

Is there a way to tell which players were Bench vs. Rostered in this function?

from espn-api.

DesiPilla avatar DesiPilla commented on May 22, 2024

In the load_roster_week function, line 214 pulls the data. If you go to
data['teams'][teamIndex]['roster']['entries'][playerIndex]['lineupSlotId'] it will return the slotId of the player for the given week. The map of slotIds are
{'QB': 0,'TQB': 1,'RB': 2,'RB/WR': 3,'WR': 4,
'WR/TE': 5,'TE': 6,'OP': 7,'DT': 8,'DE': 9,
'LB': 10,'DL': 11,'CB': 12,'S': 13,'DB': 14,
'DP': 15,'D/ST': 16,'K': 17,'P': 18,'HC': 19,
'BE': 20,'IR': 21,'': 22,'RB/WR/TE': 23, ' ': 24
}
A slotId of 20 is a bench player. Note that not every league uses every slotId, but this is the full map of possible Ids.

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024

@joshbis at the moment no. Honestly I should probably put slot_position in the Player class. However, right now you can use box_scores(week=1) to get week 1 roster benched and rostered players for a team.

from espn-api.

joshbis avatar joshbis commented on May 22, 2024

Sorry, I'm dumb and maybe this isn't the place to ask, but is this an attribute of the player? I think I was hoping it would be pullable via the weekly box scores since that already has the points.

i.e., league.teams[0].roster[0] gets me to the first player on the first team's roster.

(beyond the scope of this is that the functions are great and I'd love more syntax examples for idiots)

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024

No worries. Yeah you can get this information from the box scores function.

Here is a quick example below:

>>> box_scores = league.box_scores(week=1)
>>> box_scores[0].home_team
Team(Team 1)
>>> box_scores[0].away_team
Team(Team Viking Queen)
>>> box_scores[0].home_score
69.24
>>> box_scores[0].away_score
87.62
>>> box_scores[0].home_lineup
[Player(Kareem Hunt, points:0, projected:0), Player(Travis Kelce, points:0, projected:0), Player(Zach Ertz, points:15, projected:9), Player(Josh Gordon, points:7, projected:8), Player(Kenyan Drake, points:21, projected:8), Player(Devin Funchess, points:0, projected:0), Player(Tarik Cohen, points:11, projected:8), Player(Wil Lutz, points:10, projected:7), Player(Dion Lewis, points:4, projected:9), Player(Matthew Stafford, points:5, projected:15), Player(Ezekiel Elliott, points:20, projected:17), Player(Brandin Cooks, points:0, projected:0), Player(Kerryon Johnson, points:0, projected:0), Player(Mitchell Trubisky, points:0, projected:0), Player(Bengals D/ST, points:6, projected:-3), Player(Courtland Sutton, points:7, projected:1)]
>>> box_scores[0].home_lineup[2].points
15.1
>>> box_scores[0].home_lineup[2].projected_points
9.97
>>> box_scores[0].home_lineup[2].slot_position
'TE'
>>> box_scores[0].home_lineup[2].position
'TE'
>>> box_scores[0].home_lineup[2].name
'Zach Ertz'

I definitely need to update my documentation and add all of the fields and functions of the API to make it easier to use!

Does this answer your question?

from espn-api.

joshbis avatar joshbis commented on May 22, 2024

Nice! That's super helpful. So that -- and other individual attributes -- is pulled player by player within the week's box score? I had started playing around with this to get the full week's lineup by iterating over the home and away teams:

home = pd.concat([pd.DataFrame({ 'player_info' : box_scores[i].home_lineup, 'team' : box_scores[i].home_team}) for i in range(0,6)], ignore_index=True)

With a little tinkering I could do the same with those slot positions.

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024

Exactly, so in each box_score object has each home and away team lineup which is a list of box_player objects that have that information. Does this help with your question on #38? For that question this would be the best option at the moment.

from espn-api.

joshbis avatar joshbis commented on May 22, 2024

yes -- I can delete #38 -- it helps to understand the tool as pulling information players within rosters within leagues and not the universe of all players at ESPN.

I.e., you can find free agents but not their scores for a given week if they weren't on a roster?

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024

Correct right now you cannot. However, I am looking at the free agents endpoint and I believe I should be able to get projected and actual points of free agents. Would that be helpful field to have for free agents?

from espn-api.

joshbis avatar joshbis commented on May 22, 2024

I guess in the abstract I could imagine how it would be useful to someone using the API to analyze trades or scour the wires.

In writing this out, though, it's beyond what I was doing -- pulling actual scores and graphing how they corresponded to auction values (I already have them, but it raises a question of whether these are stored anywhere).

from espn-api.

cwendt94 avatar cwendt94 commented on May 22, 2024

Yeah definitely and a lot of added features and data were ideas from other people that I didn't even think of. You can do a lot of cool stuff with the data!

from espn-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.