To start the project, I followed these initial setup instructions:
-
Created a new repository named "nosql-challenge" specifically for this project.
-
Cloned the newly created repository to my local computer.
-
Added the Jupyter notebook starter files and the "establishments.json" file to the repository's folder.
-
Pushed the changes to GitHub.
I used the Jupyter Notebook provided in the starter code folder named "NoSQL_setup_starter.ipynb" for this section of the challenge. The steps I followed were as follows:
-
Imported the data provided in the "establishments.json" file into a MongoDB database named "uk_food" and a collection named "establishments".
-
Confirmed the successful creation of the database and loading of the data by listing the databases and collections in MongoDB.
-
Retrieved and displayed one document from the "establishments" collection using the
find_one
method. -
Assigned the "establishments" collection to a variable for further use.
I continued with the Jupyter Notebook "NoSQL_setup_starter.ipynb" for this section of the challenge. The modifications requested by the magazine editors were as follows:
-
Added a new halal restaurant, "Penang Flavours," to the database. The details of the new restaurant were provided, and I included them as a new document in the "establishments" collection.
-
Found the BusinessTypeID for "Restaurant/Cafe/Canteen" and returned only the BusinessTypeID and BusinessType fields.
-
Updated the newly added restaurant document with the BusinessTypeID found.
-
Checked the number of documents containing the Dover Local Authority and removed any establishments within the Dover Local Authority from the database.
-
Converted certain number values from strings to actual numbers using the
update_many
method.
To assist the food magazine editors, Eat Safe, Love, I conducted an exploratory analysis of the ratings data in the database. Here are some key findings:
-
Establishments with a hygiene score of 20:
- There are 41 establishments with a hygiene score of 20.
-
Highly rated establishments in London:
- There are 34 establishments in London with a rating value of 4 or higher.
-
Local Authority areas with the highest number of establishments with a hygiene score of 0: