Repository: zero-sum-seattle/python-mlb-statsapi (language: python)

Issue:
ERROR: GameInfo.___init___() missing 2 required positional arguments: 'attendance' and 'gamedurationminutes'
@KCNilssen @Mattsface 
Looks like another GameInfo.___init___() adjustment needs to be made.
Positional arguments attendance & gamedurationminutes, errors.

Call works for all but 2 gamePK's(745114 & 746083). 

**Input**
[mlb_games.csv](https://github.com/zero-sum-seattle/python-mlb-statsapi/files/14853811/mlb_games.csv)

**Output**
[mlb_games_ready.csv](https://github.com/zero-sum-seattle/python-mlb-statsapi/files/14853843/mlb_games_ready.csv)


![image](https://github.com/zero-sum-seattle/python-mlb-statsapi/assets/160516675/c20b6624-4e80-4fd5-8d7a-5d0e6159fb36)

Same code block as previous issue:

**Function**
#Function to get weather and venue for a given game_pk
def get_game_info(game_pk):
    mlb = mlbstatsapi.Mlb()
    try:
        game = mlb.get_game(game_pk)
        venue_id = game.gamedata.venue.id
        venue_name = game.gamedata.venue.name
        venue_lat = game.gamedata.venue.location.defaultcoordinates.latitude
        venue_long = game.gamedata.venue.location.defaultcoordinates.longitude
        venue_elevation = game.gamedata.venue.location.elevation
        venue_surface = game.gamedata.venue.fieldinfo.turftype
        return venue_id, venue_name, venue_lat, venue_long, venue_elevation, venue_surface
    except Exception as e:
        print(f"Error processing game_pk {game_pk}: {e}")   
        return "None", "None", "None", "None", "None", "None"

Code
#Add Game Venue and Location Detail
csv_file = 'mlb_games.csv'
df = pd.read_csv(csv_file)

# Initialize new columns
df['venue_id'] = None
df['venue_name'] = None
df['venue_latitude'] = None
df['venue_longitude'] = None
df['venue_elevation'] = None
df['venue_surface'] = None

for index, row in df.iterrows():
    game_pk = row['GamePk']
    print(game_pk)
    try:
        **venue_id, venue_name, venue_lat, venue_long, venue_elevation, venue_surface = get_game_info(game_pk)**
        df.at[index, 'venue_id'] = venue_id
        df.at[index, 'venue_name'] = venue_name
        df.at[index, 'venue_latitude'] = venue_lat
        df.at[index, 'venue_longitude'] = venue_long
        df.at[index, 'venue_elevation'] = venue_elevation
        df.at[index, 'venue_surface'] = venue_surface
    except Exception as e:
        print(f"Error processing game_pk {game_pk}: {e}")

new_column_order = [
    'Date', 'Time', 'GamePk', 'Away Team', 'Home Team', 'venue_id', 'venue_name', 'venue_latitude', 'venue_longitude', 'venue_elevation', 'venue_surface']

# Check if all columns are included in new_column_order
assert set(new_column_order) == set(df.columns), "New column order does not match DataFrame columns"

# Reindex the DataFrame with the new column order
df = df[new_column_order]

# Save the updated DataFrame back to a CSV
updated_csv_file = 'mlb_games_ready.csv'
df.to_csv(updated_csv_file, index=False)



Discussion / hints:
Thanks, ill get on it right now


Fix patch:
diff --git a/mlbstatsapi/models/attendances/attributes.py b/mlbstatsapi/models/attendances/attributes.py
index 9b8050e7..c96e5b48 100644
--- a/mlbstatsapi/models/attendances/attributes.py
+++ b/mlbstatsapi/models/attendances/attributes.py
@@ -116,9 +116,9 @@ class AttendanceRecords:
     gameshometotal: int
     year: str
     attendanceaverageytd: int
-    attendancetotal: int
     gametype: Union[AttendenceGameType, dict]
     team: Union[Team, dict]
+    attendancetotal: Optional[int] = None
     attendanceaverageaway: Optional[int] = None
     attendanceaveragehome: Optional[int] = None
     attendancehigh: Optional[int] = None
diff --git a/mlbstatsapi/models/game/gamedata/attributes.py b/mlbstatsapi/models/game/gamedata/attributes.py
index d60e61cb..9d4b32ba 100644
--- a/mlbstatsapi/models/game/gamedata/attributes.py
+++ b/mlbstatsapi/models/game/gamedata/attributes.py
@@ -165,9 +165,9 @@ class GameInfo:
     delaydurationminutes : int
         The length of delay for the game in minutes
     """
-    attendance: int
     firstpitch: str
-    gamedurationminutes: int
+    attendance: Optional[int] = None
+    gamedurationminutes: Optional[int] = None
     delaydurationminutes: Optional[int] = None
 
 
diff --git a/pyproject.toml b/pyproject.toml
index 6d211c41..d71a05c0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [project]
 name = "python-mlb-statsapi"
-version = "0.5.17"
+version = "0.5.18"
 
 authors = [
   { name="Matthew Spah", email="spahmatthew@gmail.com" },


Test patch:
diff --git a/tests/external_tests/mlb/test_mlb.py b/tests/external_tests/mlb/test_mlb.py
index f799ab2a..bc97c436 100644
--- a/tests/external_tests/mlb/test_mlb.py
+++ b/tests/external_tests/mlb/test_mlb.py
@@ -91,8 +91,8 @@ def test_mlb_get_person_id(self):
 
     def test_mlb_get_person_id_with_sportid(self):
         """mlb get_person_id should return a person id"""
-        id = self.mlb.get_people_id('Fernando Abad', sport_id=11)
-        self.assertEqual(id, [472551])
+        id = self.mlb.get_people_id('Tyler Black', sport_id=11)
+        self.assertEqual(id, [672012])
 
     def test_mlb_get_invalid_person_id(self):
         """mlb get_person_id should return empty list for invalid name"""