I have one dataframe (df) that contains home field adavantage values for various conferences. The first columns represents the home teams and the remaining column headers represent the away teams. I would like to create a new column, df1['hfa'] in the second dataframe (df1) that shows the home field advantage located in df for the respective matchups listed in df1. Below are images of the two dataframes. In excel I can achieve this with a two way lookup via Index Match. I would like to map the values from df to df1 for df1['hfa'] so that that they read: 2.5, 3.5, 4.5, etc. Thank you in advance!
I have the following code:
df1['hfa'] = df1['Home Team'].map(df.set_index('Home Team')[])
I am unsure what to use in the final argument to match the Away Team from df1 to the same column header.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.