0

I am confused about what went wrong in the code. I am trying to make a hotel recommendation system. When i run the code it complies but does not show any output.

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
Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119
Akash
  • 1
  • 2
  • Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Apr 09 '17 at 08:06
  • People will need a posting of your code to be able to help. – James Wilson Apr 09 '17 at 08:07
  • Your function doesn't print anything. – TigerhawkT3 Apr 09 '17 at 08:08
  • @TigerhawkT3 print favoriteHotels(77,3) .... i tried this even but it doesn't seem to work – Akash Apr 09 '17 at 08:15

0 Answers0