application_vnd.jupyter.stderr_output_1.png
import pandas as pd

df = pd.read_csv('../input/fivethirtyeight_ncaa_forecasts.csv')

matchups = [[str(x + 1), str(16 - x)] for x in range(8)]
df = df[df.gender == 'mens']
pre = df[df.playin_flag]
data = []
for region in pre.team_region.unique():
    data.append([])
    for _, row in pre[pre.team_region == region].iterrows():
        data[-1].extend([row.team_rating, row.rd1_win])
post = df[df.playin_flag == False]
for region in post.team_region.unique():
    for matchup in matchups:
        res = post[(post.team_region == region) & post.team_seed.isin(matchup)]
        if res.shape[0] > 1:
            data.append([])
            for _, row in res.iterrows():
                data[-1].extend([row.team_rating, row.rd2_win])

match = pd.DataFrame(data, columns=['Team1_Rating', 'Team1_Prob', 'Team2_Rating', 'Team2_Prob'])