Exemplo n.º 1
0
    def _gen_team_avg_md(self):
        team_avg_stats_df = self.team_stats_df.groupby(['TeamCode'],
                                                       as_index=False,
                                                       sort=False).mean()
        update_team_avg(team_avg_stats_df)

        header_str_list = '| Team | 2PTM/A | 2PT% | 3PTM/A | 3PT% | FTM/A | FT% | OREB | DREB | REB | AST | STL | BLK | TOV | PF | PTS |'
        align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|'
        table_str = '|' + team_avg_stats_df[[
            'TeamCode', 'FG2MA_STR', 'FG2P_STR', 'FG3MA_STR', 'FG3P_STR',
            'FTMA_STR', 'FTP_STR', 'OR', 'DR', 'REB', 'AS', 'ST', 'BS', 'TO',
            'PF', 'PTS'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        opp_team_avg_stats_df = self.team_stats_df.groupby(['OppTeamCode'],
                                                           as_index=False,
                                                           sort=False).mean()
        update_team_avg(opp_team_avg_stats_df)

        opp_header_str_list = '| Opp Team | 2PTM/A | 2PT% | 3PTM/A | 3PT% | FTM/A | FT% | OREB | DREB | REB | AST | STL | BLK | TOV | PF | PTS |'
        opp_align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|'
        opp_table_str = '|' + opp_team_avg_stats_df[[
            'OppTeamCode', 'FG2MA_STR', 'FG2P_STR', 'FG3MA_STR', 'FG3P_STR',
            'FTMA_STR', 'FTP_STR', 'OR', 'DR', 'REB', 'AS', 'ST', 'BS', 'TO',
            'PF', 'PTS'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        rank_header_str_list = '| Team | 2PTM/A | 2PT% | 3PTM/A | 3PT% | FTM/A | FT% | OREB | DREB | REB | AST | STL | BLK | TOV | PF | PTS |'
        rank_align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|'
        rank_table_str = '|' + team_avg_stats_df[[
            'TeamCode', 'FG2MA_RANK', 'FG2P_RANK', 'FG3MA_RANK', 'FG3P_RANK',
            'FTMA_RANK', 'FTP_RANK', 'OR_RANK', 'DR_RANK', 'REB_RANK',
            'AS_RANK', 'ST_RANK', 'BS_RANK', 'TO_RANK', 'PF_RANK', 'PTS_RANK'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%d',
                  encoding='utf-8',
                  index=False)[:-2]

        result_str_list = [
            header_str_list, align_str_list, table_str, '',
            opp_header_str_list, opp_align_str_list, opp_table_str, '',
            rank_header_str_list, rank_align_str_list, rank_table_str
        ]
        return '\n'.join(result_str_list) + '\n'
    def _gen_key_stats_md(self):
        league_avg_stats_df = pd.DataFrame(self.team_stats_df.mean()).T
        update_team_avg(league_avg_stats_df)

        header_str_list = '| Team | FB | 2nd | Off TO | Paint | Bench |'
        align_str_list = '|:---:|---:|---:|---:|---:|---:|'
        table_str = '|League Avg|' + league_avg_stats_df[[
            'A_FBP', 'A_SCP', 'A_PAT', 'A_PIP', 'A_PFB'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        result_str_list = [header_str_list, align_str_list, table_str]
        return '\n'.join(result_str_list) + '\n'
    def _gen_team_avg_md(self):
        league_avg_stats_df = pd.DataFrame(self.team_stats_df.mean()).T
        update_team_avg(league_avg_stats_df)

        header_str_list = '| Team | 2PTM/A | 2PT% | 3PTM/A | 3PT% | FTM/A | FT% | OREB | DREB | REB | AST | STL | BLK | TOV | PF | PTS |'
        align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|'
        table_str = '|League Avg|' + league_avg_stats_df[[
            'FG2MA_STR', 'FG2P_STR', 'FG3MA_STR', 'FG3P_STR', 'FTMA_STR',
            'FTP_STR', 'OR', 'DR', 'REB', 'AS', 'ST', 'BS', 'TO', 'PF', 'PTS'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        result_str_list = [header_str_list, align_str_list, table_str]
        return '\n'.join(result_str_list) + '\n'
Exemplo n.º 4
0
    def _gen_h2h_md(self):
        h2h_avg_stats_df = self.team_stats_df.groupby(
            ['TeamCode', 'OppTeamCode'], as_index=False, sort=False).mean()
        update_four_factors(h2h_avg_stats_df)
        update_team_avg(h2h_avg_stats_df)

        adv_header_str_list = '| Team | Opp Team | Pace | eFG% | TO Ratio | OREB% | FT Rate |'
        adv_align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|'
        adv_table_str = '|' + h2h_avg_stats_df[[
            'TeamCode', 'OppTeamCode', 'PACE', 'EFG_STR', 'TO_RATIO_STR',
            'OR_PCT_STR', 'FT_RATE_STR'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        header_str_list = '| Team | Opp Team | 2PTM/A | 2PT% | 3PTM/A | 3PT% | FTM/A | FT% | OREB | DREB | REB | AST | STL | BLK | TOV | PF | PTS |'
        align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|'
        table_str = '|' + h2h_avg_stats_df[[
            'TeamCode', 'OppTeamCode', 'FG2MA_STR', 'FG2P_STR', 'FG3MA_STR',
            'FG3P_STR', 'FTMA_STR', 'FTP_STR', 'OR', 'DR', 'REB', 'AS', 'ST',
            'BS', 'TO', 'PF', 'PTS'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        result_str_list = [
            adv_header_str_list, adv_align_str_list, adv_table_str, '',
            header_str_list, align_str_list, table_str
        ]
        return '\n'.join(result_str_list) + '\n'
Exemplo n.º 5
0
    def _gen_key_stats_md(self):
        team_avg_stats_df = self.team_stats_df.groupby(['TeamCode'],
                                                       as_index=False,
                                                       sort=False).mean()
        update_team_avg(team_avg_stats_df)

        header_str_list = '| Team | FB | 2nd | Off TO | Paint | Bench |'
        align_str_list = '|:---:|---:|---:|---:|---:|---:|'
        table_str = '|' + team_avg_stats_df[[
            'TeamCode', 'A_FBP', 'A_SCP', 'A_PAT', 'A_PIP', 'A_PFB'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        opp_team_avg_stats_df = self.team_stats_df.groupby(['OppTeamCode'],
                                                           as_index=False,
                                                           sort=False).mean()

        opp_header_str_list = '| Opp Team | FB | 2nd | Off TO | Paint | Bench |'
        opp_align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|'
        opp_table_str = '|' + opp_team_avg_stats_df[[
            'OppTeamCode', 'A_FBP', 'A_SCP', 'A_PAT', 'A_PIP', 'A_PFB'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        rank_header_str_list = '| Team | FB | 2nd | Off TO | Paint | Bench |'
        rank_align_str_list = '|:---:|---:|---:|---:|---:|---:|'
        rank_table_str = '|' + team_avg_stats_df[[
            'TeamCode', 'A_FBP_RANK', 'A_SCP_RANK', 'A_PAT_RANK', 'A_PIP_RANK',
            'A_PFB_RANK'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%d',
                  encoding='utf-8',
                  index=False)[:-2]

        h2h_avg_stats_df = self.team_stats_df.groupby(
            ['TeamCode', 'OppTeamCode'], as_index=False, sort=False).mean()
        update_team_avg(h2h_avg_stats_df)

        h2h_header_str_list = '| Team | Opp Team | FB | 2nd | Off TO | Paint | Bench |'
        h2h_align_str_list = '|:---:|---:|---:|---:|---:|---:|---:|---:|'
        h2h_table_str = '|' + h2h_avg_stats_df[[
            'TeamCode', 'OppTeamCode', 'A_FBP', 'A_SCP', 'A_PAT', 'A_PIP',
            'A_PFB'
        ]].to_csv(sep='|',
                  line_terminator='|\n|',
                  header=False,
                  float_format='%.1f',
                  encoding='utf-8',
                  index=False)[:-2]

        result_str_list = [
            header_str_list, align_str_list, table_str, '',
            opp_header_str_list, opp_align_str_list, opp_table_str, '',
            rank_header_str_list, rank_align_str_list, rank_table_str, '',
            h2h_header_str_list, h2h_align_str_list, h2h_table_str
        ]
        return '\n'.join(result_str_list) + '\n'