Open MWTyrone opened 1 year ago
So, I have some slightly good news, followed by some not so good news.
This is a known issue (the other issue is here: https://github.com/jldbc/pybaseball/issues/332), unfortunately the "fix" isn't all that great. For starters, I'm not sure how to pull that many dates at once. I wanted each individual game day stat line, so I went date by date. When I did that, I had to call a sleep() function between calls, which drastically increased the time it took to complete. It's not a great solution, but I eventually got it to work.
As far as calling all the stats over that long of a time, I'm not sure of a potential solution along the sleep() call route, sorry.
Hello,
I'm new to Python and pybaseball, and I've encountered an issue when trying to use the batting_stats_range() function to retrieve batting stats.
Here is the code I'm using:
from pybaseball import batting_stats_range import pandas as pd
Define the date range for the batting stats
batting_data = batting_stats_range('2018-01-01', '2023-12-31')
Save the data to a CSV file
batting_data.to_csv('batting_data_2018_2023.csv', index=False)
When I run this code, I receive the following error:
**Traceback (most recent call last): File "[directory]\batting_stats_pull.py", line 5, in
batting_data = batting_stats_range('2018-01-01', '2023-12-31')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "[directory]\env\Lib\site-packages\pybaseball\league_batting_stats.py", line 62, in batting_stats_range
table = get_table(soup)
^^^^^^^^^^^^^^^
File "[directory]\env\Lib\site-packages\pybaseball\league_batting_stats.py", line 28, in get_table
table = soup.find_all('table')[0]