The dataset in question is basically Olympics medal tally. The dataframe has the below mentioned columns with the Name of the country as Index.

It is a (146, 16) dataset.

#Summer Gold Silver Bronze Total #Winter Gold.1 Silver.1 Bronze.1 Total.1 #Games Gold.2 Silver.2 Bronze.2 Combined total

I am tasked with finding the country which have the biggest difference between their summer and winter gold medal counts.

def answer_two():

diff= []

for i in range(5):

diff.append(df[df.columns[1][i]]- df[df.columns[6][i]])

return diff.idxmax()

This was what i tried. But i am getting KeyError. What should I do?

Similar questions and discussions