import pandas as pd
def category_with_highest_average(df, cat_column, num_column):
solution = df.groupby(cat_column).mean().sort_values(by=[num_column])
solution = solution.tail(1)
return solution
test_case = category_with_highest_average(price_city_df, 'city', 'price')
我已经尝试了上面的代码来解决这个问题。我得到的输出为 价钱 城市 德里 1620.5
预期输出:
德里
我不确定如何只获取城市名称。请帮忙