Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. # This function loops through each restaurant dictionary in allRestaurants, grabs values for
  2. # each restaurant which is then grouped into a Series that is appended to the DataFrame
  3. for restaurantSet in allRestaurants:
  4. restaurants = restaurantSet['restaurants']
  5. for restaurant in restaurants:
  6. singleRow = [restaurant['restaurant']['name'],
  7. restaurant['restaurant']['location']['locality'],
  8. restaurant['restaurant']['location']['city'],
  9. restaurant['restaurant']['cuisines'],
  10. restaurant['restaurant']['average_cost_for_two'],
  11. restaurant['restaurant']['user_rating']['aggregate_rating'],
  12. restaurant['restaurant']['user_rating']['rating_text'],
  13. restaurant['restaurant']['user_rating']['votes']]
  14. newRow = pd.Series(singleRow, index=columns)
  15. restaurantTable = restaurantTable.append(newRow, ignore_index=True)
  16.  
  17. restaurantTable.index.name = 'id'
  18. print(restaurantTable)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement