Flipkart Reviews Sentiment Analysis

One of the most popular applications of data science is sentiment analysis of product reviews on e-commerce platforms. If you’re interested in learning how to perform Flipkart sentiment analysis with Python, this article is for you. Here, we will walk you through a complete data science project with e-commerce reviews, focusing on Flipkart product feedback to understand customer sentiments effectively.

Flipkart Reviews Sentiment Analysis using Python

The dataset we are using for this Flipkart reviews sentiment analysis project is downloaded from Kaggle. You can download the dataset from here. Let’s begin by importing the necessary Python libraries and loading the Flipkart reviews dataset:

from google.colab import drive
drive.mount('/content/drive')

file_id="1FP5P8ZWIVGVex_pyxS0bAcX15RK-GyiI"
url=f"https://drive.google.com/uc?id={file_id}"

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator

data=pd.read_csv(url)
print(data.head())

This dataset consists of six columns. Let’s check if any of these columns contain missing values:

print(data.isnull().sum())

The dataset contains a considerable number of null values, so we’ll remove all rows with missing entries before moving forward:

data=data.dropna()
print(data.isnull().sum())

Now, the dataset is free of null values. Since this project focuses on the sentiment analysis of Flipkart reviews, we will clean and preprocess the column containing the reviews before moving on to the analysis:

import nltk
import re
nltk.download('stopwords')
stemmer=nltk.SnowballStemmer("english")
from nltk.corpus import stopwords
import string
stopword=set(stopwords.words('english'))

def clean(text):
    text = str(text).lower()
    text = re.sub('\[.*?\]', '', text)
    text = re.sub('https?://\S+|www\.\S+', '', text)
    text = re.sub('<.*?>+', '', text)
    text = re.sub('[%s]' % re.escape(string.punctuation), '', text)
    text = re.sub('\n', '', text)
    text = re.sub('\w*\d\w*', '', text)
    text = [word for word in text.split(' ') if word not in stopword]
    text=" ".join(text)
    text = [stemmer.stem(word) for word in text.split(' ')]
    text=" ".join(text)
    return text
data["Review"] = data["Review"].apply(clean)

Sentiment Analysis of Flipkart Reviews

The Rate column in the dataset represents the ratings provided by each reviewer. Let’s explore how most customers rate the products they purchase on Flipkart:

ratings = data["Rate"].value_counts()
numbers = ratings.index
quantity = ratings.values

import plotly.express as px
figure = px.pie(data, 
             values=quantity, 
             names=numbers,hole = 0.5)
figure.show()

Around 59% of reviewers have rated the products they purchased from Flipkart with a full 5 out of 5 stars. Next, let’s examine the type of reviews customers leave. To do this, we will generate a word cloud to visualize the most frequently used words in the reviews column:

text = " ".join(i for i in data.Review)
stopwords = set(STOPWORDS)
wordcloud = WordCloud(stopwords=stopwords, 
                      background_color="white").generate(text)
plt.figure( figsize=(15,10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()

Now, we will analyze the sentiments of Flipkart reviews by adding three new columns – Positive, Negative, and Neutral based on the calculated sentiment scores of the reviews:

nltk.download('vader_lexicon')
sentiments = SentimentIntensityAnalyzer()
data["Positive"] = [sentiments.polarity_scores(i)["pos"] for i in data["Review"]]
data["Negative"] = [sentiments.polarity_scores(i)["neg"] for i in data["Review"]]
data["Neutral"] = [sentiments.polarity_scores(i)["neu"] for i in data["Review"]]
data = data[["Review", "Positive", "Negative", "Neutral"]]
print(data.head())

Now, let’s take a look at what the majority of reviewers think about Flipkart’s products and services:

x = sum(data["Positive"])
y = sum(data["Negative"])
z = sum(data["Neutral"])

def sentiment_score(a, b, c):
    if (a>b) and (a>c):
        print("Positive 😊 ")
    elif (b>a) and (b>c):
        print("Negative 😠 ")
    else:
        print("Neutral 🙂 ")
sentiment_score(x, y, z)

Most of the reviews fall under the neutral category. Now, let’s examine the overall counts of Positive, Negative, and Neutral sentiment scores to draw a conclusion about Flipkart reviews:

print("Positive: ", x)
print("Negative: ", y)
print("Neutral: ", z)

Conclusion

In this analysis, we explored Flipkart product reviews using a sentiment-analysis approach in Python. The review dataset was first cleaned and preprocessed, then scored across Positive, Negative, and Neutral categories using a sentiment analysis tool. The result? A majority of reviews were neutral in tone, suggesting most customers neither praise nor criticize strongly. While a solid portion gave 5-star ratings, the textual feedback trends toward cautious or balanced language. In summary, the sentiment profile of Flipkart reviews reveals that while star ratings lean high, many users express their experiences in moderate, neutral terms — a valuable insight for businesses seeking to understand genuine customer perceptions beyond ratings.




Leave a Comment