This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Number of documents in restaurants collection | |
db.restaurants.find().count() # 25359 | |
# Number of documents in neighborhoods collection | |
db.neighborhoods.find().count() # 195 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List the collecitons in the database | |
db.list_collection_names() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load restaurants database | |
db = client.sample_restaurants |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all databases | |
client.list_database_names() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing the required libraries | |
import pymongo | |
import pprint | |
import json | |
import warnings | |
warnings.filterwarnings('ignore') | |
from pprint import pprint | |
# connect to the mongoclient | |
client = pymongo.MongoClient(<connection_string>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sentiment analysis using Textblob | |
def sentiment(tweet): | |
analysis = TextBlob(tweet) | |
if analysis.sentiment.polarity > 0: | |
return 1 | |
elif analysis.sentiment.polarity == 0: | |
return 0 | |
else: | |
return -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Most commomly occuring words | |
def keywords(): | |
all_words = ' '.join([text for text in df_tweet['Clean_Tweet']]) | |
wordcloud = WordCloud(width=800, height=500, random_state=21, max_font_size=110).generate(all_words) | |
plt.figure(figsize=(10, 7)) | |
plt.imshow(wordcloud, interpolation="bilinear") | |
plt.axis('off') | |
plt.show() |