def average_gdp():
Top15['avgGDP'] = Top15[[str(year) for year in range(2006, 2016)]].apply(lambda x: x.mean(), axis=1)
avgGDP = Top15['avgGDP'].sort_values(ascending=False)
sixth_largest = avgGDP.iloc[5]
return (sixth_largest)
From Snap code above
I do like traditional one like this but. Seem not what is the purpose to create in NumPy and Pandas, How to improve this code.
I would like to create with numpy function.
Create column name avgGDP sort value on avgGDP as descending. And get the sixth largest GDP from avgGDP.