src/f1lib/data_prep.py
def prep_for_lap_plot(self) -> pd.DataFrame:
        """
        Prepare data for plotting a relative gap plot over all laps.

        Returns:
            pd.DataFrame: Dataframe with a column for each driver with an entry for each lap. 
            The enties are the relative gap for that lap from the average laoptime on that lap based on the best time + 10% (to account for pitting)
        """

        df = (
            self.get_laps()
            .assign(LapTimeNorm=lambda df: df.apply(lambda row: row['Time'] - row["LapStartTime"], axis=1))
            .assign(LapTimeSeconds=lambda df: [i.seconds for i in df["LapTimeNorm"]])
        )
        
        ref = self.get_reference(df)
        
        return (
            df
            .groupby(['LapNumber', "Driver"], as_index=False)["LapTimeSeconds"]
            .agg(('first'))
            .pivot(columns="Driver", index="LapNumber", values="LapTimeSeconds")
            .fillna(method='pad')
            .cumsum()
            .apply(lambda row: (row - ref), axis=0)
        )

        Prepare data for plotting a relative gap plot over all laps.

        Returns:
            pd.DataFrame: Dataframe with a column for each driver with an entry for each lap. 
            The enties are the relative gap for that lap from the average laoptime on that lap based on the best time + 10% (to account for pitting)
        
Prepare data for plotting a relative gap plot over all laps.
Prepare data for plotting a relative gap plot over all laps .
def prep_for_lap_plot(self) -> pd.DataFrame:
        df = (
            self.get_laps()
            .assign(LapTimeNorm=lambda df: df.apply(lambda row: row['Time'] - row["LapStartTime"], axis=1))
            .assign(LapTimeSeconds=lambda df: [i.seconds for i in df["LapTimeNorm"]])
        )
        ref = self.get_reference(df)
        return (
            df
            .groupby(['LapNumber', "Driver"], as_index=False)["LapTimeSeconds"]
            .agg(('first'))
            .pivot(columns="Driver", index="LapNumber", values="LapTimeSeconds")
            .fillna(method='pad')
            .cumsum()
            .apply(lambda row: (row - ref), axis=0)
        )
def prep_for_lap_plot ( self ) -> pd . DataFrame : df = ( self . get_laps ( ) . assign ( LapTimeNorm = lambda df : df . apply ( lambda row : row [ 'Time' ] - row [ "LapStartTime" ] , axis = 1 ) ) . assign ( LapTimeSeconds = lambda df : [ i . seconds for i in df [ "LapTimeNorm" ] ] ) ) ref = self . get_reference ( df ) return ( df . groupby ( [ 'LapNumber' , "Driver" ] , as_index = False ) [ "LapTimeSeconds" ] . agg ( ( 'first' ) ) . pivot ( columns = "Driver" , index = "LapNumber" , values = "LapTimeSeconds" ) . fillna ( method = 'pad' ) . cumsum ( ) . apply ( lambda row : ( row - ref ) , axis = 0 ) )
Prepare data for plotting a relative gap plot over all laps.
Prepare data for plotting a relative gap plot over all laps .
"""
        Prepare data for plotting a relative gap plot over all laps.

        Returns:
            pd.DataFrame: Dataframe with a column for each driver with an entry for each lap. 
            The enties are the relative gap for that lap from the average laoptime on that lap based on the best time + 10% (to account for pitting)
        """
Dataframe with a column for each driver with an entry for each lap.
The enties are the relative gap for that lap from the average laoptime on that lap based on the best time + 10% (to account for pitting)
Dataframe with a column for each driver with an entry for each lap . The enties are the relative gap for that lap from the average laoptime on that lap based on the best time + 10% ( to account for pitting )
pd.DataFrame
self