collegebaseball/boydsworld_scraper.py
def _enrich_data(df, school):
    """
    A helper function that adds the following columns to a given DataFrame:
    
        opponent (str): opponent for each game.
        runs_allowed (int): the number of runs scored by team_1 in each game
        runs_scored (int): the number of runs scored by team_1 in each game
        run_difference (int): the difference between team_1's runs scored 
            and runs allowed for each game
            
    """
    wins = df[(df["team_1"] == school) & \
              (df["team_1_score"] > df["team_2_score"])].copy()
    losses = df[(df["team_2"] == school) & \
                (df["team_1_score"] > df["team_2_score"])].copy()
    # set for wins
    wins.loc[:,"runs_scored"] = wins.loc[:,"team_1_score"]
    wins.loc[:,"runs_allowed"] = wins.loc[:,"team_2_score"]
    wins.loc[:,"opponent"] = wins.loc[:,"team_2"]
    # set for losses
    losses.loc[:,"runs_scored"] = losses.loc[:,"team_2_score"]
    losses.loc[:,"runs_allowed"] = losses.loc[:,"team_1_score"]       
    losses.loc[:,"opponent"] = losses.loc[:,"team_1"]      
    # combine dfs
    df = pd.concat([wins,losses])
    # set run difference 
    df.loc[:,"run_difference"] = df.loc[:,"runs_scored"] \
        - df.loc[:,"runs_allowed"]
    return df

    A helper function that adds the following columns to a given DataFrame:
    
        opponent (str): opponent for each game.
        runs_allowed (int): the number of runs scored by team_1 in each game
        runs_scored (int): the number of runs scored by team_1 in each game
        run_difference (int): the difference between team_1's runs scored 
            and runs allowed for each game
            
    
A helper function that adds the following columns to a given DataFrame:
opponent (str): opponent for each game.
runs_allowed (int): the number of runs scored by team_1 in each game
runs_scored (int): the number of runs scored by team_1 in each game
run_difference (int): the difference between team_1's runs scored
and runs allowed for each game
A helper function that adds the following columns to a given DataFrame : opponent ( str ) : opponent for each game . runs_allowed ( int ) : the number of runs scored by team_1 in each game runs_scored ( int ) : the number of runs scored by team_1 in each game run_difference ( int ) : the difference between team_1 ' s runs scored and runs allowed for each game
def _enrich_data(df, school):
    wins = df[(df["team_1"] == school) & \
              (df["team_1_score"] > df["team_2_score"])].copy()
    losses = df[(df["team_2"] == school) & \
                (df["team_1_score"] > df["team_2_score"])].copy()
    wins.loc[:,"runs_scored"] = wins.loc[:,"team_1_score"]
    wins.loc[:,"runs_allowed"] = wins.loc[:,"team_2_score"]
    wins.loc[:,"opponent"] = wins.loc[:,"team_2"]
    losses.loc[:,"runs_scored"] = losses.loc[:,"team_2_score"]
    losses.loc[:,"runs_allowed"] = losses.loc[:,"team_1_score"]       
    losses.loc[:,"opponent"] = losses.loc[:,"team_1"]      
    df = pd.concat([wins,losses])
    df.loc[:,"run_difference"] = df.loc[:,"runs_scored"] \
        - df.loc[:,"runs_allowed"]
    return df
def _enrich_data ( df , school ) : wins = df [ ( df [ "team_1" ] == school ) & ( df [ "team_1_score" ] > df [ "team_2_score" ] ) ] . copy ( ) losses = df [ ( df [ "team_2" ] == school ) & ( df [ "team_1_score" ] > df [ "team_2_score" ] ) ] . copy ( ) wins . loc [ : , "runs_scored" ] = wins . loc [ : , "team_1_score" ] wins . loc [ : , "runs_allowed" ] = wins . loc [ : , "team_2_score" ] wins . loc [ : , "opponent" ] = wins . loc [ : , "team_2" ] losses . loc [ : , "runs_scored" ] = losses . loc [ : , "team_2_score" ] losses . loc [ : , "runs_allowed" ] = losses . loc [ : , "team_1_score" ] losses . loc [ : , "opponent" ] = losses . loc [ : , "team_1" ] df = pd . concat ( [ wins , losses ] ) df . loc [ : , "run_difference" ] = df . loc [ : , "runs_scored" ] - df . loc [ : , "runs_allowed" ] return df
A helper function that adds the following columns to a given DataFrame:
opponent (str): opponent for each game.
A helper function that adds the following columns to a given DataFrame : opponent ( str ) : opponent for each game .
"""
    A helper function that adds the following columns to a given DataFrame:
    
        opponent (str): opponent for each game.
        runs_allowed (int): the number of runs scored by team_1 in each game
        runs_scored (int): the number of runs scored by team_1 in each game
        run_difference (int): the difference between team_1's runs scored 
            and runs allowed for each game
            
    """ # set for wins # set for losses # combine dfs # set run difference 
df
school