Perform sentiment analysis using your Facebook data and count the number of Occurrences of iyyanar in the extracted text for the code given in the following link.
import pandas as pd
from textblob import TextBlob
# Read data from Excel file
data = pd.read_csv("fb_sentiment.csv") # Replace "facebook_data.xlsx" with your file path
# Given name to count occurrences
given_name = "Iyyanar"
# Initialize counters for sentiment analysis and name occurrences
sentiment_counts = {'positive': 0, 'negative': 0, 'neutral': 0}
name_occurrences = 0
# Perform sentiment analysis and count occurrences of the given name
for index, row in data.iterrows():
# Perform sentiment analysis
blob = TextBlob(row['FBPost'])
polarity = blob.sentiment.polarity
if polarity > 0:
sentiment_counts['positive'] += 1
elif polarity < 0:
sentiment_counts['negative'] += 1
else:
sentiment_counts['neutral'] += 1
# Count occurrences of the given name
name_occurrences += row['FBPost'].lower().count(given_name.lower())
# Print sentiment analysis results
print("Sentiment Analysis Results:")
# Print occurrences of the given name
print(f"Occurrences of '{given_name}': {name_occurrences}")
Thus the sentiment analysis using your Facebook data is performed and the number of Occurrences of Krishna in the extracted text for the code is counted.