Closed DnCdad closed 1 year ago
What happens when you pass the params to get_stats?
year_stats = mlb.get_stats(stats=stats_type, groups=group_type, params)
or I would just use mlb.get_team_stats
I'm going to resolve this. Feel free to open a new issue if you are still having problems.
I am trying to retrieve MLB-related data using the MLBStatsAPI. When I execute the following code, I encounter an error:
import mlbstatsapi mlb = mlbstatsapi.Mlb()
y = 2022 stats_type = 'season' group_type = 'hitting' params = {'season':y, 'team':142}
year_stats = mlb.get_stats(stats=stats_type, groups=group_type) print(year_stats)
error:
Traceback (most recent call last): File "D:\pythonProject\get_stats__team.py", line 10, in
year_stats = mlb.get_stats(stats=stats_type, groups=group_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\GS\AppData\Local\Programs\Python\Python311\Lib\site-packages\mlbstatsapi\mlb_api.py", line 2258, in get_stats
splits = mlb_module.create_split_data(mlb_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\GS\AppData\Local\Programs\Python\Python311\Lib\site-packages\mlbstatsapi\mlb_module.py", line 110, in create_split_data
for stat in stat_data:
TypeError: 'MlbResult' object is not iterable