Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display results tables as pandas dataframe #1

Open
psychemedia opened this issue Aug 2, 2022 · 2 comments
Open

Display results tables as pandas dataframe #1

psychemedia opened this issue Aug 2, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@psychemedia
Copy link

Hi

V. interesting looking project; will be interesting to see how it can complement fast-f1.

I was wondering if there is any plan to return results tables as pandas dataframes?

@Samuel-Roach
Copy link
Owner

There aren't any current plans to return results as pandas dataframes. The idea is to keep the data as simple as possible for end-users to work with, and adding a requirement for an additional data analysis library.

That being said, I haven't worked pandas before and therefore don't know it's benefits. Perhaps a working example could provide more context for reasoning?

@psychemedia
Copy link
Author

psychemedia commented Aug 4, 2022

pandas is a widely used package for working with tabular datasets. I haven't really used ergast data in a Python context to date, but I have used it with R (Wrangling F1 data with R) and R dataframes (which are very similar to pandas dataframes).

Tabular data is trivial to work with, but wrangling the ergast data into a tabular format can be a reall faff for users, although tools are getting better that support flattening hierachical datasets, such as the pandas.normalize() function. Here's an example of how to use it using the ergast support provided in the fastf1 package:

from fastf1 import ergast
import pandas as pd

# The request returns hierarchical JSON data
erd_race = ergast.fetch_results(2022, 2, "Race")

# Flatten JSON structure to generate a 2d table / pandas dataframe
pd.json_normalize(erd_race)

Other calls supported by fastf1:

  • pd.json_normalize(ergast.fetch_season(2022)): season info
  • pd.json_normalize(ergast.fetch_weekend(2022, 2)).T: metadata about a particular race weekend

At the moment, it doesn't look like there is a function to pull back the laps data.

@Samuel-Roach Samuel-Roach added the enhancement New feature or request label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants