Data source: cuisine.csv kaggle
#ratings 2=best 1=medium 0=worst
import pandas as pd
import numpy as np
initialFrame=pd.read_csv('/Users/ezer/Downloads/RCdata/rating_final.csv')
cuisine=pd.read_csv('/Users/ezer/Downloads/RCdata/chefmozcuisine.csv')
#select restaurant with rating 2 gives boolean true false
top_rated_restaurant=initialFrame['rating']==2
#now create dataframe with rating2
frame=initialFrame[top_rated_restaurant]
# print(top_rated_restaurant.head())
result1=pd.DataFrame(frame.groupby('placeID')['rating'].count().sort_values(ascending=False))
# display 10 top rated popular restaurants
pd.DataFrame(frame.groupby('placeID')['rating'].count().sort_values(ascending=False)).head(10)
## creating dataframe of placeID
#pd.DataFrame([135085,132825,135052..],index=np.arange(5),columns=['placeID'])
#above is too manual so lets get index value only from above df
dfindexarray=result1.index
print(dfindexarray)
LenOfDf=len(dfindexarray)
most_rated_places=pd.DataFrame(dfindexarray,index=np.arange(LenOfDf),columns=['placeID'])
print(most_rated_places)
summary=pd.merge(most_rated_places,cuisine,on='placeID')
# print(summary)
# get most common cuisine in top restaurants
# summary['Rcuisine'].describe()
# get cuisines from restaurant with id 135052
summary[summary['placeID']==135052]
# Recommender system says that most popular rated Place serves Mexican food
#ratings 2=best 1=medium 0=worst
import pandas as pd
import numpy as np
initialFrame=pd.read_csv('/Users/ezer/Downloads/RCdata/rating_final.csv')
cuisine=pd.read_csv('/Users/ezer/Downloads/RCdata/chefmozcuisine.csv')
#select restaurant with rating 2 gives boolean true false
top_rated_restaurant=initialFrame['rating']==2
#now create dataframe with rating2
frame=initialFrame[top_rated_restaurant]
# print(top_rated_restaurant.head())
result1=pd.DataFrame(frame.groupby('placeID')['rating'].count().sort_values(ascending=False))
# display 10 top rated popular restaurants
pd.DataFrame(frame.groupby('placeID')['rating'].count().sort_values(ascending=False)).head(10)
| rating | |
|---|---|
| placeID | |
| 135085 | 18 |
| 132825 | 15 |
| 135052 | 14 |
#pd.DataFrame([135085,132825,135052..],index=np.arange(5),columns=['placeID'])
#above is too manual so lets get index value only from above df
dfindexarray=result1.index
print(dfindexarray)
Int64Index([135085, 132825, 135052, 135032, 135025, 135038, 135075, 132862,
135062, 135042,
LenOfDf=len(dfindexarray)
most_rated_places=pd.DataFrame(dfindexarray,index=np.arange(LenOfDf),columns=['placeID'])
print(most_rated_places)
summary=pd.merge(most_rated_places,cuisine,on='placeID')
# print(summary)
# get most common cuisine in top restaurants
# summary['Rcuisine'].describe()
# get cuisines from restaurant with id 135052
summary[summary['placeID']==135052]
| placeID | Rcuisine | |
|---|---|---|
| 2 | 135052 | Bar |
| 3 | 135052 | Bar_Pub_Brewery |
# Recommender system says that most popular rated Place serves Mexican food
No comments:
Post a Comment