Comments (13)
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.
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.
Is there a way to tell which players were Bench vs. Rostered in this function?
from espn-api.
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.
@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.
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.
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.
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.
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.
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.
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.
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.
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)
- NFL position mapping incorrect HOT 5
- Team Names not correct HOT 2
- Unable to access league data for 2018 season HOT 1
- Teams' names not updated HOT 1
- League current_week field returns 0 HOT 8
- meaning of statistics keys HOT 3
- Fix Team Data Change Working? HOT 1
- Add Owner info to Team
- Pulling League Data Errors in new season 23-24 HOT 1
- 'location' in data json doesn't exist anymore. Fix is provided HOT 2
- ESPN API Updated Key Names for Team Name HOT 1
- KeyError: 'location' in Fantasy BBall H2H Categories HOT 2
- Add back functionality to pull owner names HOT 4
- Getting "json.decoder.JSONDecodeError: Unterminated string" starting after NFL week 6 HOT 4
- Add accepted trade activity to fantasy basketball activity list HOT 3
- Player/Pick projected bid amount HOT 5
- slot_position only returning "PG" HOT 1
- Unable to get projected score of games of final completed week of season HOT 1
- Issue with Add full owner info to team commit HOT 2
- League.previousSeasons no longer an attribute? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espn-api.