Python函数没有显示任何输出。它编译但不显示所需的输出

时间:2017-04-09 08:05:23

标签: python pandas

我对代码中出了什么问题感到困惑。我正在尝试建立一个酒店推荐系统。当我运行代码时,它符合但不显示任何输出。

def favoriteHotels(activeUser,N):
    #1. subset the dataframe to have the rows corresponding to the active user
    # 2. sort by the rating in descending order
    # 3. pick the top N rows
    topHotels = pd.DataFrame.sort(datay[datay.UserId==activeUser],['Rating'],ascending=[0])[:N]
    # return the Ids of the corresponding hotels in hotels 
    return list(topHotels.Hotel_Id)

favoriteHotels(77,3) # Print the top 3 favorite Hotels of user 77

0 个答案:

没有答案