pybaseball icon indicating copy to clipboard operation
pybaseball copied to clipboard

Getting pitcher "exit" information?

Open ryan-caesar-ramos opened this issue 2 years ago • 2 comments

Baseball Reference has information on the state a starter left the game in when he was pulled (e.g. 8b --- 2 out a2 for 7.2 innings, bases empty, up by 2; or 7b 3 out a5 for 7 innings, up by five runs). I checked the docs so I'm sorry if I just missed it, but Is there a way to get this information here?

ryan-caesar-ramos avatar Jul 03 '23 15:07 ryan-caesar-ramos

Hi there Ryan-caeser-ramos & jldbc,

I have project as part of a school project (ITCS 2080 Fundamentals of Software Engineering at Lakeland Community College in Kirtland, OH) and my affinity for baseball, and came across this request, which I think would be a really valuable addition:

Baseball Reference has information on the state a starter left the game in when he was pulled (e.g. 8b --- 2 out a2 for 7.2 innings, bases empty, up by 2; or 7b 3 out a5 for 7 innings, up by five runs). I checked the docs so I'm sorry if I just missed it, but is there a way to get this information here?

This data would be really helpful for understanding pitcher usage and game context. Just wanted to echo support for this idea, it would add a lot of value for anyone doing analysis involving starters and bullpen management. Would it be possible to try to add this feature or point me in the right direction if it's already available? Thanks so much! Dominic Brindley

dominicbrindley avatar Oct 04 '25 19:10 dominicbrindley

Hey Dominic,

Best of luck in your semester! This is feasible, though it would require changes on your local copy as this request is not native to the repository.

Change No.1: You would need the bref id of each player that you'd like to analyze. Here's the docs of the function. I'll attach an example below.

from pybaseball import playerid_lookup

###### returns the bref ids of David Peterson (returns one row)
bref_id = playerid_lookup('peterson','david')['key_bbref'].iloc[0]

Change No.2: You would then need to change line 18 in in this file to this: https://www.baseball-reference.com/players/gl.fcgi?id={playerid_goes_here}&t=p&year={year_goes_here}

Next Steps: This would return the Beautiful Soup of the page, which would need to be parsed to locate the column you're interested in. I hope this provided a solid start to your research.

MancusoM avatar Oct 08 '25 02:10 MancusoM