Comments (11)
Copy that, just so you know where I am looking:
class Overview(mlbgame.object.Object):
"""Object to hold an overview of game information
Properties:
....
away_probable_pitcher_first
away_probable_pitcher_first_name
away_probable_pitcher_id
away_probable_pitcher_last
away_probable_pitcher_last_name
away_probable_pitcher_losses
away_probable_pitcher_name_display_roster
away_probable_pitcher_number
away_probable_pitcher_s_era
away_probable_pitcher_s_losses
away_probable_pitcher_s_wins
away_probable_pitcher_stats_season
away_probable_pitcher_stats_type
away_probable_pitcher_throwinghand
away_probable_pitcher_wins
I need some of this data for stuff I am working on, so I might go ahead and make some changes to grab additional stats via those gamecenter, and linescore structures. Will submit a PR with the updates if that happens.
from mlbgame.
@trevor-viljoen so games in the past won't have those attributes, but future games will (as of 3/2, this game is future http://gd2.mlb.com/components/game/mlb/year_2018/month_03/day_03/gid_2018_03_03_arimlb_lanmlb_1/linescore.xml)
I recently did #64 which grabbed the home and away probable starter attributes and if they don't exist, they should all be defaulting to an empty string, which prompted my question to the OP on if they're using a released version of mlbgame or master.
from mlbgame.
@ajbowler @panzarino Maybe we should create a FAQ for common issues/assumptions?
Potentially, this data could be retrieved from gamecenter.xml as well, which looks like it exists for old games.
from mlbgame.
@trevor-viljoen FAQ could be a good idea. Will add these new stats in the next release.
from mlbgame.
@Hisairnessag3 Slack is probably a more appropriate place for questions and you'd get more eyes and a quicker response.
This would get you key, value pairs for pitcher player IDs and how many hit by pitch. I don't see where MLB has supplied this information in any of the available XML files.
import mlbgame
from collections import Counter
# game_id = 'your_game_id'
events = mlbgame.events(game_id)
half_inn = ['top', 'bottom']
hbp_list = []
for inning in events:
for half in half_inn:
for ab in inning.__dict__[half]:
if ab.event == 'Hit By Pitch':
hbp_list.append(ab.pitcher)
hbp = Counter(hbp_list)
Or with a list comprehension
import mlbgame
from collections import Counter
# game_id = 'your_game_id'
events = mlbgame.events(game_id)
half = ['top', 'bottom']
hbp = Counter([ab.pitcher for inn in events for h in half for ab in inn.__dict__[h] if ab.event == 'Hit By Pitch'])
from mlbgame.
What's the game ID you're using for overview?
Also those changes were just merged into master a couple days ago, if you're using a released version of mlbgame those attributes won't work till next release.
from mlbgame.
Overview doesn't have a home_probable_pitcher_s_era
key. It comes from linescore.xml
: https://github.com/panzarino/mlbgame/blob/master/mlbgame/data.py#L80-L82
from mlbgame.
Quick question for you guys: Do you know any place to grab the hbp for pitchers?
from mlbgame.
import mlbgame
from collections import Counter
game = mlbgame.day(2017, 11, 1, away='Astros')[0]
events = mlbgame.game_events(game.game_id)
hb = Counter([ab.pitcher for inn in events for h in half for ab in inn.__dict__[h] if ab.event == 'Hit By Pitch'])
Counter({621121: 4})
McCullers hit 4:
Turner (by McCullers Jr.); Puig (by McCullers Jr.); Hernandez (by McCullers Jr.); Turner (by McCullers Jr.).
from mlbgame.
Whats the slack? Thanks, I am assuming I cannot grab the season HBP per game based on the xml(unless you can think of something), so I will calculate it per game and then sum after.
from mlbgame.
Slack: https://mlbgame-slack-invite.herokuapp.com/
The XML files used by mlbgame
are the same files generated by the AtBat application during a given game. Season stats would be stored in a database and not generated at run time by the application. So any season stats shown in the app would likely be the result of an API/DB query made by the application.
I'm working on v3 of mlbgame
which uses the MLB stats APIs, but they aren't well documented and some of the APIs don't seem to work, including the endpoint to get season stats.
Using the XML files, this is all you get for player pitching stats. The stat would be hb
for hit batsmen.
{
"id": 621121,
"name": "McCullers Jr.",
"name_display_first_last": "Lance McCullers Jr.",
"pos": "P",
"out": 7,
"bf": 13,
"er": 0,
"r": 0,
"h": 3,
"so": 3,
"hr": 0,
"bb": 0,
"np": 49,
"s": 27,
"w": 1,
"l": 0,
"sv": 0,
"bs": 0,
"hld": 0,
"s_ip": 7.2,
"s_h": 7,
"s_r": 3,
"s_er": 3,
"s_bb": 4,
"s_so": 6,
"game_score": 51,
"era": 3.52
}
from mlbgame.
Related Issues (20)
- `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
- Import mlbgame could not be resolved HOT 1
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.