Giter Club home page Giter Club logo

Comments (11)

Hisairnessag3 avatar Hisairnessag3 commented on September 21, 2024 2

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.

ajbowler avatar ajbowler commented on September 21, 2024 1

@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.

trevor-viljoen avatar trevor-viljoen commented on September 21, 2024 1

@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.

http://gd2.mlb.com/components/game/mlb/year_2016/month_08/day_05/gid_2016_08_05_miamlb_colmlb_1/gamecenter.xml

from mlbgame.

panzarino avatar panzarino commented on September 21, 2024 1

@trevor-viljoen FAQ could be a good idea. Will add these new stats in the next release.

from mlbgame.

trevor-viljoen avatar trevor-viljoen commented on September 21, 2024 1

@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.

ajbowler avatar ajbowler commented on September 21, 2024

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.

trevor-viljoen avatar trevor-viljoen commented on September 21, 2024

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

http://gd2.mlb.com/components/game/mlb/year_2016/month_08/day_05/gid_2016_08_05_miamlb_colmlb_1/linescore.xml

from mlbgame.

Hisairnessag3 avatar Hisairnessag3 commented on September 21, 2024

Quick question for you guys: Do you know any place to grab the hbp for pitchers?

from mlbgame.

trevor-viljoen avatar trevor-viljoen commented on September 21, 2024
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})

2017 WS Game 7

McCullers hit 4:

Turner (by McCullers Jr.); Puig (by McCullers Jr.); Hernandez (by McCullers Jr.); Turner (by McCullers Jr.).

from mlbgame.

Hisairnessag3 avatar Hisairnessag3 commented on September 21, 2024

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.

trevor-viljoen avatar trevor-viljoen commented on September 21, 2024

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)

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.