Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This function loops through each restaurant dictionary in allRestaurants, grabs values for
- # each restaurant which is then grouped into a Series that is appended to the DataFrame
- for restaurantSet in allRestaurants:
- restaurants = restaurantSet['restaurants']
- for restaurant in restaurants:
- singleRow = [restaurant['restaurant']['name'],
- restaurant['restaurant']['location']['locality'],
- restaurant['restaurant']['location']['city'],
- restaurant['restaurant']['cuisines'],
- restaurant['restaurant']['average_cost_for_two'],
- restaurant['restaurant']['user_rating']['aggregate_rating'],
- restaurant['restaurant']['user_rating']['rating_text'],
- restaurant['restaurant']['user_rating']['votes']]
- newRow = pd.Series(singleRow, index=columns)
- restaurantTable = restaurantTable.append(newRow, ignore_index=True)
- restaurantTable.index.name = 'id'
- print(restaurantTable)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement