Comments (3)
@ajbowler The existing events module contains information about the balls strikes and outs for each at bat, and I am fairly sure that just getting the last at bat will provide you with the current (live) ball, strikes, and outs.
from mlbgame.
@panzarino yes, it does look like the existing events module will work fine for this. Thanks!
from mlbgame.
@ajbowler
mlbgame.game_events("2017_11_01_houmlb_lanmlb_1")[0].top[1]
would correspond to this event:
<atbat num="2" b="0" s="0" o="0" start_tfs="002311" start_tfs_zulu="2017-11-02T00:23:11Z" end_tfs_zulu="2017-11-02T00:24:18Z" batter="608324" pitcher="506433" des="Alex Bregman reaches on a throwing error by first baseman Cody Bellinger. George Springer scores. Alex Bregman to 2nd. " des_es="Alex Bregman se embasa por error en tiro de primera base Cody Bellinger. George Springer anota Alex Bregman a 2da. " event_num="14" event="Field Error" event_es="Error de Fildeo" play_guid="05156dff-7cbc-456e-a480-9e64b00e89c2" score="T" home_team_runs="0" away_team_runs="1" b1="" b2="608324" b3="">
b1, b2, b3 are the bases. The number should be a player_id if you need that information. You can get it from mlbgame.players(game_id).home_players
or mlbgame.players(game_id).away_players
.
Something like this should work:
game_id = "2017_11_01_houmlb_lanmlb_1"
def runner(player_id, players):
player = filter(lambda p: p.id == player_id, players)
return player if player else None # or "", depending on how you want to implement it
away_players = mlbgame.players(game_id).away_players
home_players = mlbgame.players(game_id).home_players
events = mlbgame.game_events(game_id)[0].top
curr_ab = events[len(events)-1]
on_base = dict(b1=runner(curr_ab.b1, players), b2=runner(curr_ab.b2, players), b3=runner(curr_ab.b3, players))
count = dict(b=curr_ab.b, s=curr_ab.s, o=curr_ab.o)
from mlbgame.
Related Issues (20)
- Building an updating scoreboard for a day's games HOT 2
- `AtBat`'s attributes `des`, `event`, 'des_es`, and `event_es` are occasionally empty HOT 1
- Changing time zone to Pacific HOT 1
- overview(game_id) causes XMLSyntaxError HOT 2
- long return time waits? HOT 2
- Events run very slow HOT 1
- Pypi version (2.5) out of date HOT 1
- Standings pulls
- Can I get data such as if there are runners on first, second, or third, and how many balls and strikes there are? HOT 1
- game_id HOT 3
- Probable Pitchers HOT 3
- Game ID HOT 1
- Home/Away probables listed for wrong team
- mlbgame.injury() gives AttributeError HOT 4
- get_raw_box_score throws 'Could not find a game with that id.' exception for valid game_id
- Getting game events for game with unplayed bottom of final inning causes IndexError
- ValueError: Could not find a game with that id still occurring -- worked yesterday HOT 1
- 2022 Games not appearing HOT 9
- Initial setup to access MLB GD2 Database: HTTP Forbidden
- Not getting a response while running tests
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 mlbgame.