Reputation: 71
TeamA TeamB City
12 18 12
17 15 5
19 8 7
df['diff'] = numpy.abs(data_frame['TeamA'] - data_frame['TeamB'])
max = data_frame['difference'].max()
I am stuck at finding the difference max. Now, what I am looking to do is to get the winning team which should be team A in this case and then get the city number associated with that win. Any suggestion is appreciated.
Upvotes: 0
Views: 27
Reputation: 150745
Try:
diff = df['TeamA'] - df['TeamB']
max_row = diff.abs().idxmax()
team = 'Team A' if diff.loc[max_row] > 0 else 'Team B'
city = df.loc[diff.abs().idxmax(), 'City']
Upvotes: 2