Skip to content
Amazon Review Sentiment Analysis
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# Load the data
reviews_df = pd.read_csv('amazon_reviews.csv')
reviews_df# View the DataFrame Information and statistic information
reviews_df.info()
reviews_df.describe()# Plot the count plot for the ratings
sns.countplot(data=reviews_df, x='rating')
plt.show()reviews_df['verified_reviews'].astype('object')reviews_df['length'] = reviews_df['verified_reviews'].apply(lambda x: len(str(x)))reviews_df# Plot the histogram for the length
sns.histplot(data=reviews_df, x='length', bins=100)
plt.show()# Apply the describe method to get statistical summary
reviews_df.describe()# Plot the countplot for feedback
# Positive ~2800
# Negative ~250
sns.countplot(data=reviews_df, x='feedback')
plt.show()# Obtain only the positive reviews
positive = reviews_df[reviews_df['feedback']==1]
positive# Obtain only the negative reviews
negative = reviews_df[reviews_df['feedback']==0]
negative# Convert the postive review to list format
p_sentence = positive['verified_reviews'].tolist()
len(p_sentence)n_sentence = negative['verified_reviews'].tolist()
len(n_sentence)# Join all positive reviews into one large string
p_sentence_join = ' '.join(p_sentence)
print(p_sentence)