Skip to content

Commit

Permalink
FIX: properly handle missing driver info on F1 LT Api
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Jul 22, 2024
1 parent 04ec86a commit a8f7761
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fastf1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ def _drivers_from_f1_api(self, *, livedata=None):
except Exception as exc:
_logger.warning("Failed to load extended driver information!")
_logger.debug("Exception while loading driver list", exc_info=exc)
driver_info = {}
return None
else:
driver_info = collections.defaultdict(list)

Expand Down Expand Up @@ -2275,11 +2275,12 @@ def _drivers_from_f1_api(self, *, livedata=None):
driver_info['LastName']):
driver_info['FullName'].append(f"{first} {last}")

# driver info is required for joining on index (used as index),
# therefore drop rows where driver number is unavailable as they have
# an invalid index
return pd.DataFrame(driver_info, index=driver_info['DriverNumber']) \
.dropna(subset=['DriverNumber'])
# driver info is required for joining on index (used as index),
# therefore drop rows where driver number is unavailable as they
# have an invalid index
return pd.DataFrame(
driver_info, index=driver_info['DriverNumber']
).dropna(subset=['DriverNumber'])

def _drivers_results_from_ergast(
self, *, load_drivers=False, load_results=False
Expand Down

0 comments on commit a8f7761

Please sign in to comment.