MongoDB, the most popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data. This format of storage is called BSON ( similar to JSON format).
Plotting sample data from MongoDB Atlas
Before Starting to plot the sample data make sure you have created an account on the MongoDB Cloud Atlas. If you have not created follow the below steps.
- Open the MongoDB Atlas Cloud from here.
- Create the account by choosing the package suitable for you (You may also choose the free version which will be enough for this article and for learning purpose).
- Click on the Cluster view positioned at the left menu bar.
- Click on the Ellipses button
(...)and select Load Sample Dataset.
- After the sample dataset is added then click on the connect button.
- Then whitelist the IP address (choose your current IP address or type the 0.0.0.0/0 IP for allowing it to access from everywhere. Click the button shown in the below image.
- Then click connect to applications button.
- Copy the cluster_uri and paste it to a “course_cluster_uri”.
- Import PyMongo and Axes3d and Matplotlib.
- Go to MongoDB Atlas Cloud by signing in.
- Paste the “course_cluster_uri” following the above steps.
- Get the client using “pymongo.MongoClient(course_url)” .
- Now set the query to filtering conditions and criteria by removing outliers that are clearly bad data.
- Convert cursor into a list.
- Now set the plot as “scatter/bar/hist” and also set Title, X-axis label, Y-axis label and legends.
- Don’t forget to type plt.show().
Below is the implementation.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course