Giter Club home page Giter Club logo

Comments (7)

trevor-viljoen avatar trevor-viljoen commented on July 23, 2024 1

@Hisairnessag3 Something like this would probably work.

player_stats = mlbgame.player_stats(game.game_id)
pi_home = sum([p.s_h for p in player_stats.home_pitching])

from mlbgame.

Hisairnessag3 avatar Hisairnessag3 commented on July 23, 2024

Also I should probably make another issue for this but when iterating through stats for the year I get this traceback:

Traceback (most recent call last):
  File "/Users/austinglugla/PycharmProjects/mlb/mlb.py", line 117, in <module>
    test_stats(games)
  File "/Users/austinglugla/PycharmProjects/mlb/mlb.py", line 58, in test_stats
    box_score = mlbgame.box_score(game.game_id)
  File "/Users/austinglugla/anaconda2/lib/python2.7/site-packages/mlbgame/__init__.py", line 190, in box_score
    data = mlbgame.game.box_score(game_id)
  File "/Users/austinglugla/anaconda2/lib/python2.7/site-packages/mlbgame/game.py", line 240, in box_score
    home = x.attrib['home']
  File "src/lxml/etree.pyx", line 2469, in lxml.etree._Attrib.__getitem__ (src/lxml/etree.c:72092)
KeyError: 'home'

from mlbgame.

panzarino avatar panzarino commented on July 23, 2024

@Hisairnessag3 try updating to the latest version. I'm pretty sure a similar bug fix was just released. If that doesn't work, I'll look into it further.

from mlbgame.

Hisairnessag3 avatar Hisairnessag3 commented on July 23, 2024

Yes, I am up to date.

from mlbgame.

trevor-viljoen avatar trevor-viljoen commented on July 23, 2024

The pitching TeamStats object doesn't have a s_h property. It comes from this line in the xml:
<pitching team_flag="home" out="27" h="8" r="4" er="2" bb="3" so="11" hr="0" bf="39" era="1.50">.

Each individual pitcher has a s_h property:

<pitcher id="434378" name="Verlander" name_display_first_last="Justin Verlander" pos="P" out="6" bf="8" er="0" r="0" h="1" so="2" hr="0" bb="1" np="17" s="11" w="0" l="0" sv="0" bs="0" hld="0" s_ip="2.0" s_h="1" s_r="0" s_er="0" s_bb="1" s_so="2" game_score="50" era="0.00"/>

Here's a sample boxscore: http://gd2.mlb.com/components/game/mlb/year_2017/month_02/day_25/gid_2017_02_25_houmlb_detmlb_1/boxscore.xml

from mlbgame.

panzarino avatar panzarino commented on July 23, 2024

Closing as @trevor-viljoen has provided the correct answer.

from mlbgame.

Hisairnessag3 avatar Hisairnessag3 commented on July 23, 2024

Any way to grab those types of season stats at the game level? Would be really helpful for what I am doing.

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.