def run():
    cl_qualifiers_raw = read_input("cl_qualifiers")
    el_qualifiers_raw = read_input("el_qualifiers")

    cl_qualifiers, el_qualifiers = [], []
    for season in range(SEASON_START, SEASON_END):
        cl_single_season = cl_qualifiers_raw[cl_qualifiers_raw["Year"] ==
                                             season].copy()
        el_single_season = el_qualifiers_raw[el_qualifiers_raw["Year"] ==
                                             season].copy()

        cl_qualifiers.append(
            calculate_record(
                fill_results(prepare_for_record(cl_single_season)), season))
        el_qualifiers.append(
            calculate_record(
                fill_results(prepare_for_record(el_single_season)), season))

    cl_qualifiers_record = pd.concat(cl_qualifiers)
    el_qualifiers_record = pd.concat(el_qualifiers)

    rename_qualifiers_cols(cl_qualifiers_record, "CLQ")
    rename_qualifiers_cols(el_qualifiers_record, "ELQ")

    save_output_to_csv(cl_qualifiers_record, "cl_qualifiers_aggregated")
    save_output_to_csv(el_qualifiers_record, "el_qualifiers_aggregated")
def run():
    teams_general = read_input("teams_general")
    teams_detailed = read_input("teams_detailed")
    teams = pd.merge(teams_general,
                     teams_detailed,
                     left_index=True,
                     right_index=True)
    change_transfers_to_numerical(teams)
    change_age_to_numerical(teams)
    teams = convert_units(teams)
    save_output_to_csv(teams, "teams")
Ejemplo n.º 3
0
def run():
    teams_full_record = cleanup_dataframe(read_input("teams_full_record"))
    my_uefa = read_input("uefa_ranking")

    weight = calculate_weight(teams_full_record, my_uefa)

    teams_full_record = teams_full_record.merge(weight,
                                                how="left",
                                                left_on=["Country", "Year"],
                                                right_on=["Country", "Year"])

    calculate_score_for_single_cup(teams_full_record, "EL")
    calculate_score_for_single_cup(teams_full_record, "CL")
    calculate_score_for_single_cup(teams_full_record, "ELQ")
    calculate_score_for_single_cup(teams_full_record, "CLQ")
    calculate_score_for_single_cup(teams_full_record, "DL")

    teams_full_record.replace(np.nan, 0, inplace=True)

    calculate_score(teams_full_record)

    save_output_to_csv(teams_full_record, "teams_score")
def run():
    teams_dl_uefa_record = read_input("teams_dl_uefa_record")
    cl_qualifiers = read_input("cl_qualifiers_aggregated")
    el_qualifiers = read_input("el_qualifiers_aggregated")

    teams_dl_uefa_record["TransfermarktId"] = teams_dl_uefa_record[
        "Link"].str.split(expand=True, pat='/')[4].astype(int)

    teams_dl_uefa_qualifiers_record = pd.merge(
        teams_dl_uefa_record,
        cl_qualifiers,
        how="left",
        left_on=["TransfermarktId", "Year"],
        right_on=["TransfermarktId",
                  "Year"]).merge(el_qualifiers,
                                 how="left",
                                 left_on=["TransfermarktId", "Year"],
                                 right_on=["TransfermarktId", "Year"])
    teams_dl_uefa_qualifiers_record.replace(np.nan, 0, inplace=True)

    save_output_to_csv(teams_dl_uefa_qualifiers_record,
                       "teams_dl_uefa_qualifiers_record")
Ejemplo n.º 5
0
def run():
    transfermarkt = read_input("teams")
    soccerway = read_input("season_results")
    uefa = read_input("european_cups_record")

    transfermarkt_soccerway = merge_transfermarkt_soccerway(
        transfermarkt, soccerway)
    _, teams_complete = keep_complete(transfermarkt_soccerway)

    uefa_results_manually, uefa_match = match_teams(teams_complete, uefa, 0.5)
    uefa_match.update(manual_map_uefa)
    teams_complete['Team'] = teams_complete['Team'].map(uefa_match)

    uefa_ids = uefa[['Team', 'Country', 'UefaId']].drop_duplicates()
    teams_with_uefa_id = pd.merge(teams_complete,
                                  uefa_ids[["UefaId", "Team"]],
                                  how="left",
                                  left_on=["Team"],
                                  right_on=["Team"])

    el_results = uefa[uefa['Competition'] == 'UEFA Europa League']
    el_results = rename_qualifiers_cols(el_results, "AllEL")

    cl_results = uefa[uefa['Competition'] == 'UEFA Champions League']
    cl_results = rename_qualifiers_cols(cl_results, "AllCL")

    teams_dl_uefa_record = pd.merge(teams_with_uefa_id,
                                    cl_results,
                                    how='left',
                                    left_on=['UefaId', 'Year'],
                                    right_on=['UefaId', 'Year']).merge(
                                        el_results,
                                        how='left',
                                        left_on=['UefaId', 'Year'],
                                        right_on=['UefaId', 'Year'])

    save_output_to_csv(teams_dl_uefa_record, "teams_dl_uefa_record")
def run():
    teams_dl_uefa_qualifiers_record = read_input(
        "teams_dl_uefa_qualifiers_record")

    calculate_playoff_record(teams_dl_uefa_qualifiers_record, "CL")
    calculate_playoff_record(teams_dl_uefa_qualifiers_record, "EL")

    calculate_matches_played(teams_dl_uefa_qualifiers_record, "CL")
    calculate_matches_played(teams_dl_uefa_qualifiers_record, "EL")
    calculate_matches_played(teams_dl_uefa_qualifiers_record, "CLQ")
    calculate_matches_played(teams_dl_uefa_qualifiers_record, "ELQ")

    # correct mistaken results - Celitc, Legia season CL qualifiers 2015
    teams_dl_uefa_qualifiers_record.loc[695:695, 'WinsCL'] = 0.0
    teams_dl_uefa_qualifiers_record.loc[695:695, 'LossesCL'] = 0.0

    teams_dl_uefa_qualifiers_record.loc[635:635, 'WinsCL'] = 0.0
    teams_dl_uefa_qualifiers_record.loc[635:635, 'LossesCL'] = 0.0

    cols_output = [
        'Country', 'Year', 'Team', 'Link', 'Value', 'Difference', 'Age',
        'AbroadPlayers', 'StadiumCapacity', 'StadiumName', 'SquadSize',
        'TopArrival', 'TopDeparture', 'IncomeValue', 'ExpenditureValues',
        'OverallBalance', 'MatchesPlayedDL', 'WinsDL', 'DrawsDL', 'LossesDL',
        'GoalsScored', 'GoalsAgainst', 'GoalsBalance', 'Points', 'Round',
        'UefaId', 'TransfermarktId', 'CompetitionAllCL', 'StageAllCL',
        'WinsAllCL', 'DrawsAllCL', 'LossesAllCL', 'MatchesPlayedAllCL',
        'WinsCLQ', 'DrawsCLQ', 'LossesCLQ', 'MatchesPlayedCLQ', 'WinsCL',
        'DrawsCL', 'LossesCL', 'MatchesPlayedCL', 'CompetitionAllEL',
        'StageAllEL', 'WinsAllEL', 'DrawsAllEL', 'LossesAllEL',
        'MatchesPlayedAllEL', 'WinsELQ', 'DrawsELQ', 'LossesELQ',
        'MatchesPlayedELQ', 'WinsEL', 'DrawsEL', 'LossesEL', 'MatchesPlayedEL'
    ]

    save_output_to_csv(teams_dl_uefa_qualifiers_record[cols_output],
                       "teams_full_record")
 def details_clubs_links(self):
     return list(read_input("teams_general")["Link"])
Ejemplo n.º 8
0
 def similar_leagues_top_tier_links(self):
     return read_input("similar_leagues_top_tier_links")