This file contains hidden or 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
| new1 = Trump_reviews.groupby('Expression Label').count() | |
| x = list(new1['Sentiment_Polarity']) | |
| y = list(new1.index) | |
| tuple_list = list(zip(x,y)) | |
| df = pd.DataFrame(tuple_list, columns=['x','y']) | |
| df['color'] = 'blue' | |
| df['color'][1] = 'red' | |
| df['color'][2] = 'green' |
This file contains hidden or 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
| Biden_reviews['Expression Label'] = np.where(Biden_reviews['Sentiment_Polarity']>0,'positive', 'negative') | |
| Biden_reviews['Expression Label'][Biden_reviews.Sentiment_Polarity ==0] = "Neutral" | |
| Biden_reviews.tail() |
This file contains hidden or 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
| Trump_reviews['Expression Label'] = np.where(Trump_reviews['Sentiment_Polarity']>0,'positive', 'negative') | |
| Trump_reviews['Expression Label'][Trump_reviews.Sentiment_Polarity ==0] = "Neutral" | |
| Trump_reviews.tail() |
This file contains hidden or 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
| def find_pol(review): | |
| return TextBlob(review).sentiment.polarity | |
| Biden_reviews['Sentiment_Polarity'] = Biden_reviews['text'].apply(find_pol) | |
| Biden_reviews.tail() |
This file contains hidden or 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
| def find_pol(review): | |
| return TextBlob(review).sentiment.polarity | |
| Trump_reviews['Sentiment_Polarity'] = Trump_reviews['text'].apply(find_pol) | |
| Trump_reviews.tail() |
This file contains hidden or 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
| import csv | |
| import tweepy | |
| import ssl | |
| # Oauth keys | |
| consumer_key = "QN3CzI2gScYvDsrhhaL2SRbOPrC" | |
| consumer_secret = "AQU3NwlOqUb1aKxgy0Nk22H5k8jjj0tYJ4nlFRLFZQJCA07TLCJMm" | |
| access_token = "969527167221563392-35WKxHqmuLkkqfe1zqQbmSN276vZTFAbz" | |
| access_token_secret = "wplE6EPMtyqNRESaBV175jRzU5ffgq934nX3h2dNQ7rnzarg" |
This file contains hidden or 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
| text_blob_object1 = TextBlob(Trump_reviews['text'][10]) | |
| print(text_blob_object1.sentiment) | |
| text_blob_object2 = TextBlob(Biden_reviews['text'][500]) | |
| print(text_blob_object2.sentiment) |
This file contains hidden or 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
| # Install Libraries | |
| pip install -U textblob | |
| pip install pandas | |
| pip nstall numpy | |
| pip install plotly | |
| pip install seaborn | |
| pip install matplotlib | |
| pip install wordcloud | |
| # Import Libraries |
This file contains hidden or 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
| import urllib.request,sys,time | |
| from bs4 import BeautifulSoup | |
| import requests | |
| import pandas as pd | |
| pagesToGet= 1 | |
| upperframe=[] | |
| for page in range(1,pagesToGet+1): | |
| print('processing page :', page) |
NewerOlder