Text Data Analysis: Working with Google Reviews
Welcome to this blog post! In this project, we will be working with a Google reviews dataset from a cleaning company. Our goal is to demonstrate how to work with text data and report and visualize our findings.
Text data analysis is an essential skill for anyone working with data today. With the increasing use of social media and online platforms, text data has become one of the most common types of data available. It’s a rich source of information that can provide insights into customer opinions, preferences, and experiences.
For this project, we will be focusing on how to clean and process text data from Google reviews. We will also demonstrate how to perform sentiment analysis on the reviews and extract key insights using data visualization techniques.
By the end of this project, you will have a solid understanding of how to work with text data, and how to use Python libraries such as Pandas, Matplotlib, and Seaborn to visualize and report your findings. So, let’s get started!
Google Reviews Project¶
The dataset used in this project was scrapped from google maps reviews
IMPORT LIBRARIES¶
#data manipulation and analysis library.
import numpy as np
import pandas as pd
# For visualizations
import matplotlib.pyplot as plt
import seaborn as sns
# For regular expressions
import re
# For handling string
import string
# For performing mathematical operations
import math
#set the maximum number of rows and columns to display
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
LOAD DATA¶
df=pd.read_csv('ddeep_reviews.csv')
DATASET OVERVIEW¶
#First 10 rows
df.head(10)
name | ratings | user_tot_reviews | date_review | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 reviews | 3 months ago | Excellent service. Very professional and extre… | Like | Response from the owner | 3 months ago | Thanks for your feedback Mordi. |
1 | Barbara McHardy | 5 | 2 reviews | 2 months ago | Excellent used this company twice the first ti… | Like | Response from the owner | 2 months ago | thanks for your feedback Barbara. |
2 | Terri Ho | 5 | 3 reviews | 7 months ago | Used the end of tenancy cleaning and carpet an… | Like | Response from the owner | 7 months ago | Thanks for your feedback Terri. |
3 | Nasima | 4 | 4 reviews | 3 months ago | they were very good but missed some cleaning i… | NaN | Response from the owner | 3 months ago | Thanks for your feedback Nasima. |
4 | Alpha Connections | 2 | 2 reviews | a year ago | We booked a deep clean of our house. The staff… | Like | Response from the owner | 11 months ago | Hi,\nwe are very sorry to hear this from you. … |
5 | Bethany Thornton | 5 | 1 review | a year ago | Highly recommend D Deep Cleaning. The house wa… | NaN | Response from the owner | 11 months ago | thanks for your feedback Bethany. |
6 | Linda Benin | 5 | 2 reviews | 2 months ago | I was amazed how clean the house was. They did… | Like | Response from the owner | 2 months ago | Thanks for your feedback Linda. |
7 | Greta Britain | 5 | 3 reviews | 5 months ago | D Deep Cleaning did an end of tenancy clean an… | Like | Response from the owner | 5 months ago | Thanks for your feedback Greta |
8 | Tidjane Minougou | 5 | 1 review | a year ago | Called D Deep cleaning services at last minute… | Like | Response from the owner | 11 months ago | Thanks for your feedback Tidjane |
9 | Greta Gasser | 5 | 10 reviews | 10 months ago | We had a good experience with D Deep Cleaning … | Like | Response from the owner | 10 months ago | Thanks for your feedback Greta. |
#Last 10 rows
df.tail(10)
name | ratings | user_tot_reviews | date_review | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|---|
42 | shubina tabassum | 5 | 1 review | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your review Shubina. |
43 | Gurvinder Kaur | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Mr kaur |
44 | Chelby Morley | 5 | 1 review | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Chelby. |
45 | Abibou Dembele | 5 | NaN | a year ago | NaN | NaN | Response from the owner | a year ago | THANKS |
46 | Syed Gillani | 5 | NaN | 10 months ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Syed. |
47 | Rebecca Barter | 5 | 5 reviews | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Rebecca. |
48 | Joanne Mccormack | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Joanne. |
49 | Jack Dunderdale | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Jack. |
50 | Mark Bridge | 5 | NaN | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback mark. |
51 | Basit khan | 5 | 2 reviews | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks your feedback Basit. |
#random sample of 20 rows
df.sample(20)
name | ratings | user_tot_reviews | date_review | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|---|
4 | Alpha Connections | 2 | 2 reviews | a year ago | We booked a deep clean of our house. The staff… | Like | Response from the owner | 11 months ago | Hi,\nwe are very sorry to hear this from you. … |
23 | Joy Wokadala | 5 | 1 review | 9 months ago | Francis who came to clean the place was great…. | Like | Response from the owner | 9 months ago | Thanks for your feedback Joy. |
0 | Wole Mordi | 5 | 2 reviews | 3 months ago | Excellent service. Very professional and extre… | Like | Response from the owner | 3 months ago | Thanks for your feedback Mordi. |
46 | Syed Gillani | 5 | NaN | 10 months ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Syed. |
21 | Ali Embleton | 5 | 1 review | a year ago | On time and extremely polite and efficient.\nH… | Like | Response from the owner | 10 months ago | THANKS FOR YOUR FEEDBACK ALI. |
5 | Bethany Thornton | 5 | 1 review | a year ago | Highly recommend D Deep Cleaning. The house wa… | NaN | Response from the owner | 11 months ago | thanks for your feedback Bethany. |
39 | Mark Marshall | 5 | 3 reviews | 11 months ago | NaN | NaN | Response from the owner | 11 months ago | Thanks for your feedback mark. |
36 | Laura Frielichova | 5 | 1 review | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Laura |
28 | Aaliyah Qadeer | 5 | 2 reviews | a year ago | Pleased with the outcome, they did a fabulous … | NaN | Response from the owner | 11 months ago | thanks for your feedback Aalaiyah |
51 | Basit khan | 5 | 2 reviews | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks your feedback Basit. |
33 | Aziz Hussain | 5 | NaN | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Mr Hussain. |
40 | Radek Podolka | 5 | NaN | a year ago | NaN | NaN | Response from the owner | a year ago | Thanks for the feedback radek |
26 | Lucy Acheampong | 5 | 1 review | 10 months ago | D deep cleaning service provided us a very h… | Like | Response from the owner | 10 months ago | Thank for your feedback Lucy. |
43 | Gurvinder Kaur | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Mr kaur |
49 | Jack Dunderdale | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Jack. |
9 | Greta Gasser | 5 | 10 reviews | 10 months ago | We had a good experience with D Deep Cleaning … | Like | Response from the owner | 10 months ago | Thanks for your feedback Greta. |
22 | Ciaran Jones | 5 | 4 reviews | a year ago | Highly recommend this very professional and th… | Like | Response from the owner | 11 months ago | thanks for your feedback Ciaran |
32 | Mario Attan | 5 | NaN | a year ago | NaN | NaN | Response from the owner | 11 months ago | Thanks for you feedback Mario |
29 | Max Hunter | 5 | 3 reviews | a year ago | Communication very good, clean very thorough a… | Like | Response from the owner | a year ago | THANK FOR YOUR FEEDBACK MAX. |
19 | Darren Hilton | 5 | 1 review | a year ago | Would highly recommend, needed a deep clean on… | Like | Response from the owner | 11 months ago | thanks for your feed Darren. |
Define function to get an overview of the data
def data_overview(data, title):
overview_analysis = {f'{title}':[data.shape[1], data.shape[0],
data.isnull().any(axis=1).sum(),
data.isnull().any(axis=1).sum()/len(data)*100,
data.duplicated().sum(),
data.duplicated().sum()/len(data)*100,
sum((data.dtypes == 'object') & (data.nunique() > 2)),
sum((data.dtypes == 'object') & (data.nunique() < 3)),
data.select_dtypes(include=['int64', 'float64']).shape[1]
]}
overview_analysis=pd.DataFrame(overview_analysis, index=['Columns','Rows','Missing_Values','Missing_Values %',
'Duplicates', 'Duplicates %','Categorical_variables','Boolean_variables','Numerical_variables']).round(2)
return overview_analysis
data_overview(df, "Data_Overview")
Data_Overview | |
---|---|
Columns | 9.00 |
Rows | 52.00 |
Missing_Values | 28.00 |
Missing_Values % | 53.85 |
Duplicates | 0.00 |
Duplicates % | 0.00 |
Categorical_variables | 6.00 |
Boolean_variables | 2.00 |
Numerical_variables | 1.00 |
Define function to have an overview of the variables
def variables_overview_func (data):
variable_details = {'unique':data.nunique(),
'dtype':data.dtypes,
'null':data.isna().sum(),
'null %':data.isna().sum()/len(data)*100
}
variable_details = pd.DataFrame(variable_details)
return variable_details
variables_overview=variables_overview_func(df)
variables_overview
unique | dtype | null | null % | |
---|---|---|---|---|
name | 52 | object | 0 | 0.000000 |
ratings | 3 | int64 | 0 | 0.000000 |
user_tot_reviews | 13 | object | 12 | 23.076923 |
date_review | 10 | object | 0 | 0.000000 |
text | 31 | object | 21 | 40.384615 |
review_liked | 1 | object | 28 | 53.846154 |
response | 1 | object | 0 | 0.000000 |
response_date | 11 | object | 0 | 0.000000 |
response_text | 51 | object | 0 | 0.000000 |
SUMMARY OF STATISTICS¶
Compute summary of statistics for the numerical columns in the DataFrame.
df.describe()
ratings | |
---|---|
count | 52.000000 |
mean | 4.923077 |
std | 0.435942 |
min | 2.000000 |
25% | 5.000000 |
50% | 5.000000 |
75% | 5.000000 |
max | 5.000000 |
Compute summary of statistics for the categorical columns in the DataFrame
df.describe(include='object')
name | user_tot_reviews | date_review | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|
count | 52 | 40 | 52 | 31 | 24 | 52 | 52 | 52 |
unique | 52 | 13 | 10 | 31 | 1 | 1 | 11 | 51 |
top | Wole Mordi | 1 review | a year ago | Excellent service. Very professional and extre… | Like | Response from the owner | 10 months ago | Thanks for your feedback mark. |
freq | 1 | 11 | 28 | 1 | 24 | 52 | 17 | 2 |
Clean the dataset¶
user_tot_reviews column¶
The ‘user_tot_reviews’ column of our dataset contains a mix of data types, including integers, strings, and NaN values. However, for our current project, we only require the numerical values from this column. We can apply a regular expression pattern to extract only the digits. Once we have successfully extracted the numerical values, we will then convert the data type from objects to integers. This conversion is important as it allows us to perform numerical operations on the data and to facilitate further analysis. By performing this data type conversion, we ensure that the ‘user_tot_reviews’ column contains only numerical values and is in a format that can be easily used in our analysis.
# Define a function to extract only digits from a string
def extract_digits(s):
pattern = r'\d+'
matches = re.findall(pattern, s)
return (''.join(matches))
# Apply the extract_digits function to the 'user_tot_reviews' column
df['user_tot_reviews'] = df['user_tot_reviews'].apply(lambda x: extract_digits(str(x)))
To transform the column dtype to int for analysis purposes, we need to replace empty strings with NaN using the replace method. Since the column dtype is an object, all rows with NaN values were considered as strings and therefore returned no numbers, resulting in empty cells.
df
name | ratings | user_tot_reviews | date_review | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 | 3 months ago | Excellent service. Very professional and extre… | Like | Response from the owner | 3 months ago | Thanks for your feedback Mordi. |
1 | Barbara McHardy | 5 | 2 | 2 months ago | Excellent used this company twice the first ti… | Like | Response from the owner | 2 months ago | thanks for your feedback Barbara. |
2 | Terri Ho | 5 | 3 | 7 months ago | Used the end of tenancy cleaning and carpet an… | Like | Response from the owner | 7 months ago | Thanks for your feedback Terri. |
3 | Nasima | 4 | 4 | 3 months ago | they were very good but missed some cleaning i… | NaN | Response from the owner | 3 months ago | Thanks for your feedback Nasima. |
4 | Alpha Connections | 2 | 2 | a year ago | We booked a deep clean of our house. The staff… | Like | Response from the owner | 11 months ago | Hi,\nwe are very sorry to hear this from you. … |
5 | Bethany Thornton | 5 | 1 | a year ago | Highly recommend D Deep Cleaning. The house wa… | NaN | Response from the owner | 11 months ago | thanks for your feedback Bethany. |
6 | Linda Benin | 5 | 2 | 2 months ago | I was amazed how clean the house was. They did… | Like | Response from the owner | 2 months ago | Thanks for your feedback Linda. |
7 | Greta Britain | 5 | 3 | 5 months ago | D Deep Cleaning did an end of tenancy clean an… | Like | Response from the owner | 5 months ago | Thanks for your feedback Greta |
8 | Tidjane Minougou | 5 | 1 | a year ago | Called D Deep cleaning services at last minute… | Like | Response from the owner | 11 months ago | Thanks for your feedback Tidjane |
9 | Greta Gasser | 5 | 10 | 10 months ago | We had a good experience with D Deep Cleaning … | Like | Response from the owner | 10 months ago | Thanks for your feedback Greta. |
10 | Adam Elshazly | 5 | 1 | 3 months ago | what a guy dennis is honestly, very nice and h… | Like | Response from the owner | 3 months ago | Thanks for your feedback Adam. |
11 | Stephanie Wasek | 5 | 47 | 11 months ago | Hired DDeep Cleaning for a spring clean/mid-te… | NaN | Response from the owner | 11 months ago | Thanks for your feedback Stephanie. |
12 | Faizan ali (the best one) | 5 | 35 | a week ago | Awesome. Recommend by a friend and now I’ll be… | Like | Response from the owner | a week ago | Thanks of your feedback |
13 | Amanda | 5 | 2 | 5 months ago | They came to do a deep clean at short notice a… | Like | Response from the owner | 5 months ago | Thanks for your feedback Amanda |
14 | Amy Zarepour | 5 | 5 | 10 months ago | Thorough cleaning of carpets, Francis did a wo… | NaN | Response from the owner | 10 months ago | Thanks for your feedback Amy. |
15 | Paula Oliver | 5 | 34 | 3 months ago | Great service, lovely people and highly recomm… | NaN | Response from the owner | 3 months ago | Thanks for your feedback Paula. |
16 | R H | 5 | 2 | 5 months ago | Very pleased with the cleaning. They worked ha… | Like | Response from the owner | 4 months ago | Thanks for your feedback \n Rukhsana. |
17 | Ekari Lynn | 5 | 3 | 3 months ago | Amazing and professional service. My house was… | Like | Response from the owner | 3 months ago | Thanks for your feedback Lynn. |
18 | Eman Ayaz | 5 | 2 | a year ago | I was very impressed with their services for a… | Like | Response from the owner | 11 months ago | thanks for your feedback Eman.\nwe are always … |
19 | Darren Hilton | 5 | 1 | a year ago | Would highly recommend, needed a deep clean on… | Like | Response from the owner | 11 months ago | thanks for your feed Darren. |
20 | Dale Rab | 5 | 25 | a year ago | Amazing cleaning company.\n\nMoved to a new ho… | Like | Response from the owner | 11 months ago | thank for your feedback Rab |
21 | Ali Embleton | 5 | 1 | a year ago | On time and extremely polite and efficient.\nH… | Like | Response from the owner | 10 months ago | THANKS FOR YOUR FEEDBACK ALI. |
22 | Ciaran Jones | 5 | 4 | a year ago | Highly recommend this very professional and th… | Like | Response from the owner | 11 months ago | thanks for your feedback Ciaran |
23 | Joy Wokadala | 5 | 1 | 9 months ago | Francis who came to clean the place was great…. | Like | Response from the owner | 9 months ago | Thanks for your feedback Joy. |
24 | Labi Demba | 5 | 1 | 11 months ago | D Deep cleaning services provided us high qual… | NaN | Response from the owner | 11 months ago | Thanks for your feedback labi. |
25 | Sarah Fornarelli | 5 | 2 | a year ago | Absolutely amazing service. These guys went ab… | Like | Response from the owner | 11 months ago | THANKS FOR YOUR FEEDBACK SARAH |
26 | Lucy Acheampong | 5 | 1 | 10 months ago | D deep cleaning service provided us a very h… | Like | Response from the owner | 10 months ago | Thank for your feedback Lucy. |
27 | Mark Carrigan | 5 | 58 | a year ago | Seriously impressive service. Did an extremely… | Like | Response from the owner | a year ago | THANK FOR YOUR FEEDBACK MARK |
28 | Aaliyah Qadeer | 5 | 2 | a year ago | Pleased with the outcome, they did a fabulous … | NaN | Response from the owner | 11 months ago | thanks for your feedback Aalaiyah |
29 | Max Hunter | 5 | 3 | a year ago | Communication very good, clean very thorough a… | Like | Response from the owner | a year ago | THANK FOR YOUR FEEDBACK MAX. |
30 | G. Mujtaba | 5 | 64 | a month ago | Excellent service. Raymond was great in assess… | Like | Response from the owner | 3 weeks ago | Thanks for your feedback Mr Mujtaba. |
31 | Márius Šimkovič | 5 | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Márius |
32 | Mario Attan | 5 | a year ago | NaN | NaN | Response from the owner | 11 months ago | Thanks for you feedback Mario | |
33 | Aziz Hussain | 5 | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Mr Hussain. | |
34 | Angelika Nalepka | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for you feed back Angelika. | |
35 | Adam Hogarth | 5 | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Adam |
36 | Laura Frielichova | 5 | 1 | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Laura |
37 | S Mia | 5 | 89 | a year ago | NaN | NaN | Response from the owner | a year ago | THANKS FOR YOUR FEEDBACK Tj |
38 | Shan Woo | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your free Shan | |
39 | Mark Marshall | 5 | 3 | 11 months ago | NaN | NaN | Response from the owner | 11 months ago | Thanks for your feedback mark. |
40 | Radek Podolka | 5 | a year ago | NaN | NaN | Response from the owner | a year ago | Thanks for the feedback radek | |
41 | Godfred Barwhah | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Godfred | |
42 | shubina tabassum | 5 | 1 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your review Shubina. |
43 | Gurvinder Kaur | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Mr kaur | |
44 | Chelby Morley | 5 | 1 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Chelby. |
45 | Abibou Dembele | 5 | a year ago | NaN | NaN | Response from the owner | a year ago | THANKS | |
46 | Syed Gillani | 5 | 10 months ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Syed. | |
47 | Rebecca Barter | 5 | 5 | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Rebecca. |
48 | Joanne Mccormack | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Joanne. | |
49 | Jack Dunderdale | 5 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Jack. | |
50 | Mark Bridge | 5 | 9 months ago | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback mark. | |
51 | Basit khan | 5 | 2 | a year ago | NaN | NaN | Response from the owner | 10 months ago | thanks your feedback Basit. |
# Replace empty strings with NaN
df['user_tot_reviews'] = df['user_tot_reviews'].replace('', np.nan)
#Transform to data type with int64 as it supports nan values compared to using only int
df['user_tot_reviews']=df['user_tot_reviews'].astype('Int64')
date_review column¶
we will first rename it to date_review then we will extract the number of days since the review and then transform the column date type into int for analysis purpose
# Rename column 'date_review' to 'review_time_period'
df = df.rename(columns={'date_review': 'review_time_period'})
# Define a function to map string values to number of months or weeks
def to_timedelta(s):
if 'year' in s:
pattern = r'\d+'
matches = re.findall(pattern, s)
if matches:
return pd.Timedelta(int(''.join(matches)) * 365, unit='D')
elif not matches:
return pd.Timedelta(1 * 365, unit='D')
elif 'month' in s:
pattern = r'\d+'
matches = re.findall(pattern, s)
if matches:
return pd.Timedelta(int(''.join(matches)) * 30, unit='D')
elif not matches:
return pd.Timedelta(1 * 30, unit='D')
elif 'week' in s:
pattern = r'\d+'
matches = re.findall(pattern, s)
if matches:
return pd.Timedelta(int(''.join(matches)) * 7, unit='D')
elif not matches:
return pd.Timedelta(1 * 7, unit='D')
return pd.NaT
df['review_time_period'].apply(to_timedelta)
0 90 days 1 60 days 2 210 days 3 90 days 4 365 days 5 365 days 6 60 days 7 150 days 8 365 days 9 300 days 10 90 days 11 330 days 12 7 days 13 150 days 14 300 days 15 90 days 16 150 days 17 90 days 18 365 days 19 365 days 20 365 days 21 365 days 22 365 days 23 270 days 24 330 days 25 365 days 26 300 days 27 365 days 28 365 days 29 365 days 30 30 days 31 365 days 32 365 days 33 270 days 34 365 days 35 365 days 36 365 days 37 365 days 38 365 days 39 330 days 40 365 days 41 365 days 42 365 days 43 365 days 44 365 days 45 365 days 46 300 days 47 270 days 48 365 days 49 365 days 50 270 days 51 365 days Name: review_time_period, dtype: timedelta64[ns]
# Convert the 'review_time_period' column to a datetime type using the to_timedelta function
df['review_time_period'] = df['review_time_period'].apply(to_timedelta)
df
name | ratings | user_tot_reviews | review_time_period | text | review_liked | response | response_date | response_text | |
---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 | 90 days | Excellent service. Very professional and extre… | Like | Response from the owner | 3 months ago | Thanks for your feedback Mordi. |
1 | Barbara McHardy | 5 | 2 | 60 days | Excellent used this company twice the first ti… | Like | Response from the owner | 2 months ago | thanks for your feedback Barbara. |
2 | Terri Ho | 5 | 3 | 210 days | Used the end of tenancy cleaning and carpet an… | Like | Response from the owner | 7 months ago | Thanks for your feedback Terri. |
3 | Nasima | 4 | 4 | 90 days | they were very good but missed some cleaning i… | NaN | Response from the owner | 3 months ago | Thanks for your feedback Nasima. |
4 | Alpha Connections | 2 | 2 | 365 days | We booked a deep clean of our house. The staff… | Like | Response from the owner | 11 months ago | Hi,\nwe are very sorry to hear this from you. … |
5 | Bethany Thornton | 5 | 1 | 365 days | Highly recommend D Deep Cleaning. The house wa… | NaN | Response from the owner | 11 months ago | thanks for your feedback Bethany. |
6 | Linda Benin | 5 | 2 | 60 days | I was amazed how clean the house was. They did… | Like | Response from the owner | 2 months ago | Thanks for your feedback Linda. |
7 | Greta Britain | 5 | 3 | 150 days | D Deep Cleaning did an end of tenancy clean an… | Like | Response from the owner | 5 months ago | Thanks for your feedback Greta |
8 | Tidjane Minougou | 5 | 1 | 365 days | Called D Deep cleaning services at last minute… | Like | Response from the owner | 11 months ago | Thanks for your feedback Tidjane |
9 | Greta Gasser | 5 | 10 | 300 days | We had a good experience with D Deep Cleaning … | Like | Response from the owner | 10 months ago | Thanks for your feedback Greta. |
10 | Adam Elshazly | 5 | 1 | 90 days | what a guy dennis is honestly, very nice and h… | Like | Response from the owner | 3 months ago | Thanks for your feedback Adam. |
11 | Stephanie Wasek | 5 | 47 | 330 days | Hired DDeep Cleaning for a spring clean/mid-te… | NaN | Response from the owner | 11 months ago | Thanks for your feedback Stephanie. |
12 | Faizan ali (the best one) | 5 | 35 | 7 days | Awesome. Recommend by a friend and now I’ll be… | Like | Response from the owner | a week ago | Thanks of your feedback |
13 | Amanda | 5 | 2 | 150 days | They came to do a deep clean at short notice a… | Like | Response from the owner | 5 months ago | Thanks for your feedback Amanda |
14 | Amy Zarepour | 5 | 5 | 300 days | Thorough cleaning of carpets, Francis did a wo… | NaN | Response from the owner | 10 months ago | Thanks for your feedback Amy. |
15 | Paula Oliver | 5 | 34 | 90 days | Great service, lovely people and highly recomm… | NaN | Response from the owner | 3 months ago | Thanks for your feedback Paula. |
16 | R H | 5 | 2 | 150 days | Very pleased with the cleaning. They worked ha… | Like | Response from the owner | 4 months ago | Thanks for your feedback \n Rukhsana. |
17 | Ekari Lynn | 5 | 3 | 90 days | Amazing and professional service. My house was… | Like | Response from the owner | 3 months ago | Thanks for your feedback Lynn. |
18 | Eman Ayaz | 5 | 2 | 365 days | I was very impressed with their services for a… | Like | Response from the owner | 11 months ago | thanks for your feedback Eman.\nwe are always … |
19 | Darren Hilton | 5 | 1 | 365 days | Would highly recommend, needed a deep clean on… | Like | Response from the owner | 11 months ago | thanks for your feed Darren. |
20 | Dale Rab | 5 | 25 | 365 days | Amazing cleaning company.\n\nMoved to a new ho… | Like | Response from the owner | 11 months ago | thank for your feedback Rab |
21 | Ali Embleton | 5 | 1 | 365 days | On time and extremely polite and efficient.\nH… | Like | Response from the owner | 10 months ago | THANKS FOR YOUR FEEDBACK ALI. |
22 | Ciaran Jones | 5 | 4 | 365 days | Highly recommend this very professional and th… | Like | Response from the owner | 11 months ago | thanks for your feedback Ciaran |
23 | Joy Wokadala | 5 | 1 | 270 days | Francis who came to clean the place was great…. | Like | Response from the owner | 9 months ago | Thanks for your feedback Joy. |
24 | Labi Demba | 5 | 1 | 330 days | D Deep cleaning services provided us high qual… | NaN | Response from the owner | 11 months ago | Thanks for your feedback labi. |
25 | Sarah Fornarelli | 5 | 2 | 365 days | Absolutely amazing service. These guys went ab… | Like | Response from the owner | 11 months ago | THANKS FOR YOUR FEEDBACK SARAH |
26 | Lucy Acheampong | 5 | 1 | 300 days | D deep cleaning service provided us a very h… | Like | Response from the owner | 10 months ago | Thank for your feedback Lucy. |
27 | Mark Carrigan | 5 | 58 | 365 days | Seriously impressive service. Did an extremely… | Like | Response from the owner | a year ago | THANK FOR YOUR FEEDBACK MARK |
28 | Aaliyah Qadeer | 5 | 2 | 365 days | Pleased with the outcome, they did a fabulous … | NaN | Response from the owner | 11 months ago | thanks for your feedback Aalaiyah |
29 | Max Hunter | 5 | 3 | 365 days | Communication very good, clean very thorough a… | Like | Response from the owner | a year ago | THANK FOR YOUR FEEDBACK MAX. |
30 | G. Mujtaba | 5 | 64 | 30 days | Excellent service. Raymond was great in assess… | Like | Response from the owner | 3 weeks ago | Thanks for your feedback Mr Mujtaba. |
31 | Márius Šimkovič | 5 | 5 | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Márius |
32 | Mario Attan | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 11 months ago | Thanks for you feedback Mario |
33 | Aziz Hussain | 5 | <NA> | 270 days | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Mr Hussain. |
34 | Angelika Nalepka | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for you feed back Angelika. |
35 | Adam Hogarth | 5 | 5 | 365 days | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Adam |
36 | Laura Frielichova | 5 | 1 | 365 days | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Laura |
37 | S Mia | 5 | 89 | 365 days | NaN | NaN | Response from the owner | a year ago | THANKS FOR YOUR FEEDBACK Tj |
38 | Shan Woo | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | Thanks for your free Shan |
39 | Mark Marshall | 5 | 3 | 330 days | NaN | NaN | Response from the owner | 11 months ago | Thanks for your feedback mark. |
40 | Radek Podolka | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | a year ago | Thanks for the feedback radek |
41 | Godfred Barwhah | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Godfred |
42 | shubina tabassum | 5 | 1 | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your review Shubina. |
43 | Gurvinder Kaur | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | Thanks for your feedback Mr kaur |
44 | Chelby Morley | 5 | 1 | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Chelby. |
45 | Abibou Dembele | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | a year ago | THANKS |
46 | Syed Gillani | 5 | <NA> | 300 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Syed. |
47 | Rebecca Barter | 5 | 5 | 270 days | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback Rebecca. |
48 | Joanne Mccormack | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Joanne. |
49 | Jack Dunderdale | 5 | <NA> | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks for your feedback Jack. |
50 | Mark Bridge | 5 | <NA> | 270 days | NaN | NaN | Response from the owner | 9 months ago | Thanks for your feedback mark. |
51 | Basit khan | 5 | 2 | 365 days | NaN | NaN | Response from the owner | 10 months ago | thanks your feedback Basit. |
def extract_digits1(s):
pattern = r'(\d+)\s+.*'
match = re.match(pattern, s)
if match:
return match.group(1)
else:
return ''
df['review_time_period'] = df['review_time_period'].astype(str).apply(extract_digits1).astype('Int64')
review_liked¶
This column refers to whether the review received any likes from other users. If the value is “like,” it means that the review did not receive any likes from users. If the value is “nan,” it means that the review received at least one like from a user. To avoid confusion with the “like” value, we will convert “like” to “no” and “nan” to “yes.”
# Replace "like" to "no"
df['review_liked'] = df['review_liked'].replace('Like', 'no')
# Replace "nan" to "yes"
df['review_liked'] = df['review_liked'].fillna('yes')
response_date¶
we will first rename it to days_since_response then we will extract the number of days since the response and then transform the column date type into int for analysis purpose
# Rename column 'response_date' to 'date_since_response'
df = df.rename(columns={'response_date': 'days_since_reponse'})
df['days_since_reponse'].apply(to_timedelta)
0 90 days 1 60 days 2 210 days 3 90 days 4 330 days 5 330 days 6 60 days 7 150 days 8 330 days 9 300 days 10 90 days 11 330 days 12 7 days 13 150 days 14 300 days 15 90 days 16 120 days 17 90 days 18 330 days 19 330 days 20 330 days 21 300 days 22 330 days 23 270 days 24 330 days 25 330 days 26 300 days 27 365 days 28 330 days 29 365 days 30 21 days 31 300 days 32 330 days 33 270 days 34 300 days 35 300 days 36 300 days 37 365 days 38 300 days 39 330 days 40 365 days 41 300 days 42 300 days 43 300 days 44 300 days 45 365 days 46 300 days 47 270 days 48 300 days 49 300 days 50 270 days 51 300 days Name: days_since_reponse, dtype: timedelta64[ns]
df['days_since_reponse'] = df['days_since_reponse'].apply(to_timedelta)
df['days_since_reponse'] = df['days_since_reponse'].astype(str).apply(extract_digits1).astype('Int64')
Add a new column named cleaned to fill the nan values in text which refers to ratings with no comment
df['cleaned'] = df['text'].fillna('NOCOMMENT')
#view final data
df
name | ratings | user_tot_reviews | review_time_period | text | review_liked | response | days_since_reponse | response_text | cleaned | |
---|---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 | 90 | Excellent service. Very professional and extre… | no | Response from the owner | 90 | Thanks for your feedback Mordi. | Excellent service. Very professional and extre… |
1 | Barbara McHardy | 5 | 2 | 60 | Excellent used this company twice the first ti… | no | Response from the owner | 60 | thanks for your feedback Barbara. | Excellent used this company twice the first ti… |
2 | Terri Ho | 5 | 3 | 210 | Used the end of tenancy cleaning and carpet an… | no | Response from the owner | 210 | Thanks for your feedback Terri. | Used the end of tenancy cleaning and carpet an… |
3 | Nasima | 4 | 4 | 90 | they were very good but missed some cleaning i… | yes | Response from the owner | 90 | Thanks for your feedback Nasima. | they were very good but missed some cleaning i… |
4 | Alpha Connections | 2 | 2 | 365 | We booked a deep clean of our house. The staff… | no | Response from the owner | 330 | Hi,\nwe are very sorry to hear this from you. … | We booked a deep clean of our house. The staff… |
5 | Bethany Thornton | 5 | 1 | 365 | Highly recommend D Deep Cleaning. The house wa… | yes | Response from the owner | 330 | thanks for your feedback Bethany. | Highly recommend D Deep Cleaning. The house wa… |
6 | Linda Benin | 5 | 2 | 60 | I was amazed how clean the house was. They did… | no | Response from the owner | 60 | Thanks for your feedback Linda. | I was amazed how clean the house was. They did… |
7 | Greta Britain | 5 | 3 | 150 | D Deep Cleaning did an end of tenancy clean an… | no | Response from the owner | 150 | Thanks for your feedback Greta | D Deep Cleaning did an end of tenancy clean an… |
8 | Tidjane Minougou | 5 | 1 | 365 | Called D Deep cleaning services at last minute… | no | Response from the owner | 330 | Thanks for your feedback Tidjane | Called D Deep cleaning services at last minute… |
9 | Greta Gasser | 5 | 10 | 300 | We had a good experience with D Deep Cleaning … | no | Response from the owner | 300 | Thanks for your feedback Greta. | We had a good experience with D Deep Cleaning … |
10 | Adam Elshazly | 5 | 1 | 90 | what a guy dennis is honestly, very nice and h… | no | Response from the owner | 90 | Thanks for your feedback Adam. | what a guy dennis is honestly, very nice and h… |
11 | Stephanie Wasek | 5 | 47 | 330 | Hired DDeep Cleaning for a spring clean/mid-te… | yes | Response from the owner | 330 | Thanks for your feedback Stephanie. | Hired DDeep Cleaning for a spring clean/mid-te… |
12 | Faizan ali (the best one) | 5 | 35 | 7 | Awesome. Recommend by a friend and now I’ll be… | no | Response from the owner | 7 | Thanks of your feedback | Awesome. Recommend by a friend and now I’ll be… |
13 | Amanda | 5 | 2 | 150 | They came to do a deep clean at short notice a… | no | Response from the owner | 150 | Thanks for your feedback Amanda | They came to do a deep clean at short notice a… |
14 | Amy Zarepour | 5 | 5 | 300 | Thorough cleaning of carpets, Francis did a wo… | yes | Response from the owner | 300 | Thanks for your feedback Amy. | Thorough cleaning of carpets, Francis did a wo… |
15 | Paula Oliver | 5 | 34 | 90 | Great service, lovely people and highly recomm… | yes | Response from the owner | 90 | Thanks for your feedback Paula. | Great service, lovely people and highly recomm… |
16 | R H | 5 | 2 | 150 | Very pleased with the cleaning. They worked ha… | no | Response from the owner | 120 | Thanks for your feedback \n Rukhsana. | Very pleased with the cleaning. They worked ha… |
17 | Ekari Lynn | 5 | 3 | 90 | Amazing and professional service. My house was… | no | Response from the owner | 90 | Thanks for your feedback Lynn. | Amazing and professional service. My house was… |
18 | Eman Ayaz | 5 | 2 | 365 | I was very impressed with their services for a… | no | Response from the owner | 330 | thanks for your feedback Eman.\nwe are always … | I was very impressed with their services for a… |
19 | Darren Hilton | 5 | 1 | 365 | Would highly recommend, needed a deep clean on… | no | Response from the owner | 330 | thanks for your feed Darren. | Would highly recommend, needed a deep clean on… |
20 | Dale Rab | 5 | 25 | 365 | Amazing cleaning company.\n\nMoved to a new ho… | no | Response from the owner | 330 | thank for your feedback Rab | Amazing cleaning company.\n\nMoved to a new ho… |
21 | Ali Embleton | 5 | 1 | 365 | On time and extremely polite and efficient.\nH… | no | Response from the owner | 300 | THANKS FOR YOUR FEEDBACK ALI. | On time and extremely polite and efficient.\nH… |
22 | Ciaran Jones | 5 | 4 | 365 | Highly recommend this very professional and th… | no | Response from the owner | 330 | thanks for your feedback Ciaran | Highly recommend this very professional and th… |
23 | Joy Wokadala | 5 | 1 | 270 | Francis who came to clean the place was great…. | no | Response from the owner | 270 | Thanks for your feedback Joy. | Francis who came to clean the place was great…. |
24 | Labi Demba | 5 | 1 | 330 | D Deep cleaning services provided us high qual… | yes | Response from the owner | 330 | Thanks for your feedback labi. | D Deep cleaning services provided us high qual… |
25 | Sarah Fornarelli | 5 | 2 | 365 | Absolutely amazing service. These guys went ab… | no | Response from the owner | 330 | THANKS FOR YOUR FEEDBACK SARAH | Absolutely amazing service. These guys went ab… |
26 | Lucy Acheampong | 5 | 1 | 300 | D deep cleaning service provided us a very h… | no | Response from the owner | 300 | Thank for your feedback Lucy. | D deep cleaning service provided us a very h… |
27 | Mark Carrigan | 5 | 58 | 365 | Seriously impressive service. Did an extremely… | no | Response from the owner | 365 | THANK FOR YOUR FEEDBACK MARK | Seriously impressive service. Did an extremely… |
28 | Aaliyah Qadeer | 5 | 2 | 365 | Pleased with the outcome, they did a fabulous … | yes | Response from the owner | 330 | thanks for your feedback Aalaiyah | Pleased with the outcome, they did a fabulous … |
29 | Max Hunter | 5 | 3 | 365 | Communication very good, clean very thorough a… | no | Response from the owner | 365 | THANK FOR YOUR FEEDBACK MAX. | Communication very good, clean very thorough a… |
30 | G. Mujtaba | 5 | 64 | 30 | Excellent service. Raymond was great in assess… | no | Response from the owner | 21 | Thanks for your feedback Mr Mujtaba. | Excellent service. Raymond was great in assess… |
31 | Márius Šimkovič | 5 | 5 | 365 | NaN | yes | Response from the owner | 300 | thanks for your feedback Márius | NOCOMMENT |
32 | Mario Attan | 5 | <NA> | 365 | NaN | yes | Response from the owner | 330 | Thanks for you feedback Mario | NOCOMMENT |
33 | Aziz Hussain | 5 | <NA> | 270 | NaN | yes | Response from the owner | 270 | Thanks for your feedback Mr Hussain. | NOCOMMENT |
34 | Angelika Nalepka | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | thanks for you feed back Angelika. | NOCOMMENT |
35 | Adam Hogarth | 5 | 5 | 365 | NaN | yes | Response from the owner | 300 | Thanks for your feedback Adam | NOCOMMENT |
36 | Laura Frielichova | 5 | 1 | 365 | NaN | yes | Response from the owner | 300 | Thanks for your feedback Laura | NOCOMMENT |
37 | S Mia | 5 | 89 | 365 | NaN | yes | Response from the owner | 365 | THANKS FOR YOUR FEEDBACK Tj | NOCOMMENT |
38 | Shan Woo | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | Thanks for your free Shan | NOCOMMENT |
39 | Mark Marshall | 5 | 3 | 330 | NaN | yes | Response from the owner | 330 | Thanks for your feedback mark. | NOCOMMENT |
40 | Radek Podolka | 5 | <NA> | 365 | NaN | yes | Response from the owner | 365 | Thanks for the feedback radek | NOCOMMENT |
41 | Godfred Barwhah | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | Thanks for your feedback Godfred | NOCOMMENT |
42 | shubina tabassum | 5 | 1 | 365 | NaN | yes | Response from the owner | 300 | thanks for your review Shubina. | NOCOMMENT |
43 | Gurvinder Kaur | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | Thanks for your feedback Mr kaur | NOCOMMENT |
44 | Chelby Morley | 5 | 1 | 365 | NaN | yes | Response from the owner | 300 | thanks for your feedback Chelby. | NOCOMMENT |
45 | Abibou Dembele | 5 | <NA> | 365 | NaN | yes | Response from the owner | 365 | THANKS | NOCOMMENT |
46 | Syed Gillani | 5 | <NA> | 300 | NaN | yes | Response from the owner | 300 | thanks for your feedback Syed. | NOCOMMENT |
47 | Rebecca Barter | 5 | 5 | 270 | NaN | yes | Response from the owner | 270 | Thanks for your feedback Rebecca. | NOCOMMENT |
48 | Joanne Mccormack | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | thanks for your feedback Joanne. | NOCOMMENT |
49 | Jack Dunderdale | 5 | <NA> | 365 | NaN | yes | Response from the owner | 300 | thanks for your feedback Jack. | NOCOMMENT |
50 | Mark Bridge | 5 | <NA> | 270 | NaN | yes | Response from the owner | 270 | Thanks for your feedback mark. | NOCOMMENT |
51 | Basit khan | 5 | 2 | 365 | NaN | yes | Response from the owner | 300 | thanks your feedback Basit. | NOCOMMENT |
REVIEW TEXT PROCESSING¶
Tokenization¶
In natural language processing (NLP), the process of removing punctuation marks from text is called “tokenization” or “text normalization”. It involves removing all punctuation marks from the text and converting the text to lowercase.
Expand Contractions¶
Contractions are the shortened versions of words like don’t for do not and how’ll for how will. These are used to reduce the speaking and writing time of words. We need to expand these contractions for a better analysis of the reviews.
We will use a dictionary of common English contractions that for mapping the contractions to their expanded forms:
import contractions
# Dictionary of English Contractions
contractions_dict = { "ain't": "are not","'s":" is","aren't": "are not",
"can't": "cannot","can't've": "cannot have",
"'cause": "because","could've": "could have","couldn't": "could not",
"couldn't've": "could not have", "didn't": "did not","doesn't": "does not",
"don't": "do not","hadn't": "had not","hadn't've": "had not have",
"hasn't": "has not","haven't": "have not","he'd": "he would",
"he'd've": "he would have","he'll": "he will", "he'll've": "he will have",
"how'd": "how did","how'd'y": "how do you","how'll": "how will",
"I'd": "I would", "I'd've": "I would have","I'll": "I will",
"I'll've": "I will have","I'm": "I am","I've": "I have", "isn't": "is not",
"it'd": "it would","it'd've": "it would have","it'll": "it will",
"it'll've": "it will have", "let's": "let us","ma'am": "madam",
"mayn't": "may not","might've": "might have","mightn't": "might not",
"mightn't've": "might not have","must've": "must have","mustn't": "must not",
"mustn't've": "must not have", "needn't": "need not",
"needn't've": "need not have","o'clock": "of the clock","oughtn't": "ought not",
"oughtn't've": "ought not have","shan't": "shall not","sha'n't": "shall not",
"shan't've": "shall not have","she'd": "she would","she'd've": "she would have",
"she'll": "she will", "she'll've": "she will have","should've": "should have",
"shouldn't": "should not", "shouldn't've": "should not have","so've": "so have",
"that'd": "that would","that'd've": "that would have", "there'd": "there would",
"there'd've": "there would have", "they'd": "they would",
"they'd've": "they would have","they'll": "they will",
"they'll've": "they will have", "they're": "they are","they've": "they have",
"to've": "to have","wasn't": "was not","we'd": "we would",
"we'd've": "we would have","we'll": "we will","we'll've": "we will have",
"we're": "we are","we've": "we have", "weren't": "were not","what'll": "what will",
"what'll've": "what will have","what're": "what are", "what've": "what have",
"when've": "when have","where'd": "where did", "where've": "where have",
"who'll": "who will","who'll've": "who will have","who've": "who have",
"why've": "why have","will've": "will have","won't": "will not",
"won't've": "will not have", "would've": "would have","wouldn't": "would not",
"wouldn't've": "would not have","y'all": "you all", "y'all'd": "you all would",
"y'all'd've": "you all would have","y'all're": "you all are",
"y'all've": "you all have", "you'd": "you would","you'd've": "you would have",
"you'll": "you will","you'll've": "you will have", "you're": "you are",
"you've": "you have"}
# Regular expression for finding contractions
contractions_re=re.compile('(%s)' % '|'.join(contractions_dict.keys()))
# Function for expanding contractions
def expand_contractions(text,contractions_dict=contractions_dict):
def replace(match):
return contractions_dict[match.group(0)]
return contractions_re.sub(replace, text)
# Expanding Contractions in the reviews on a new column
df['cleaned']=df['cleaned'].apply(lambda x:expand_contractions(x))
Lowercase the reviews¶
Natural Language Processing (NLP) models process text as sequences of characters or words to understand the meaning behind them. However, in many cases, different forms of the same word can have different meanings, such as “buy” and “Buy.” This can lead to errors in the analysis, as the models may treat these forms as separate entities.
To overcome this problem, one common solution is to convert all words to lowercase. This ensures that words with different capitalization are treated the same way by the NLP models. For example, “buy” and “Buy” would both be converted to “buy.”
In Python, the lower() function can be used to convert a string to lowercase. This function is commonly used in NLP preprocessing to standardize the capitalization of text before feeding it to an NLP model.
df['cleaned']=df['cleaned'].apply(lambda x: x.lower())
Remove digits and words containing digits¶
When processing text data for Natural Language Processing (NLP) tasks, it is often necessary to clean the text by removing certain types of words or characters that are not useful for the analysis. One common type of unwanted text is numbers and words that contain digits, as they typically do not contribute much to the meaning of the text.
To remove these unwanted elements, regular expressions can be used in conjunction with lambda functions. Regular expressions are patterns that can be used to match specific types of text, while lambda functions are anonymous functions that can be used to apply operations to the text.
In this case, the lambda function is used to apply the regular expression pattern that matches any word containing a digit or any standalone digit in the text data. The re module in Python provides various regular expression functions and methods to work with regular expressions. By using this combination of tools, unwanted numbers and words containing digits can be removed from the text data, which can help improve the accuracy of NLP models.
- df[‘cleaned’]: This selects the ‘cleaned’ column of the DataFrame df.
- .apply(lambda x: …): This applies a function to each element of the ‘cleaned’ column. The function in this case is a lambda function.
- re.sub(‘\w\d\w‘,”, x): This is the lambda function that replaces any alphanumeric character that contains a digit with an empty string.
- The regular expression \w\d\w matches any sequence of characters that includes at least one digit.
- The re.sub() function replaces any match with an empty string, effectively removing the match from the string.
df['cleaned']=df['cleaned'].apply(lambda x: re.sub('\w*\d\w*','', x))
Remove Punctuations¶
Punctuation marks are an essential part of English grammar as they help us to express ourselves clearly and effectively. However, when it comes to text analysis, punctuations can actually hinder our understanding of the text. Punctuations such as commas, hyphens, full stops, and quotation marks, among others, can create noise in our text data that is not useful for analysis. For example, if we want to perform text analysis to identify the most commonly used words in a text, it would be unhelpful to include punctuation marks such as full stops and commas in our analysis. Removing punctuations from text data not only simplifies the text but also ensures that our analysis is accurate and meaningful. Therefore, it is crucial to remove punctuations from text data before performing text analysis.
- df[‘cleaned’]: This selects the ‘cleaned’ column of the DataFrame df.
- .apply(lambda x: …): This applies a function to each element of the ‘cleaned’ column. The function in this case is a lambda function.
- re.sub(‘[%s]’ % re.escape(string.punctuation), ”, x): This is the lambda function that removes all punctuation marks from the input string.
- The regular expression […] matches any single character that is included inside the square brackets. In this case, it includes all the punctuation marks in the string.punctuation string.
- The re.escape() function is used to escape any characters in string.punctuation that have special meaning in regular expressions.
- The re.sub() function replaces all punctuation marks in the input string x with an empty string ”
df['cleaned']=df['cleaned'].apply(lambda x: re.sub('[%s]' % re.escape(string.punctuation), '', x))
remove special characters¶
The regular expression r'[^a-zA-z0-9]’ is a pattern that matches any character that is not a letter (upper or lower case) or a digit. Here’s a breakdown of the pattern:
[^…] is a negated character set, which matches any character that is not in the set of characters inside the square brackets. a-zA-Z is a range of characters that includes all upper and lowercase letters of the English alphabet. 0-9 is a range of characters that includes all digits. So the pattern [^a-zA-z0-9] matches any character that is not a letter or a digit, including whitespace, punctuation marks, and other special characters.
# Create a function to remove special characters
def remove_special_characters(text):
pat = r'[^a-zA-z0-9]'
return re.sub(pat, ' ', text)
# lets apply this function
df['cleaned'] = df.apply(lambda x: remove_special_characters(x['cleaned']), axis = 1)
Removing extra spaces¶
replace multiple consecutive spaces in the ‘cleaned’ column of a pandas DataFrame with a single space.
- df[‘cleaned’]: This selects the ‘cleaned’ column of the DataFrame df.
- .apply(lambda x: …): This applies a function to each element of the ‘cleaned’ column. The function in this case is a lambda function.
- re.sub(‘ +’,’ ‘,x): This is the lambda function that replaces multiple consecutive spaces in the input string x with a single space.
- The regular expression ‘ +’ matches one or more spaces in the input string. The re.sub() function replaces any match with a single space ‘ ‘. This way, it reduces multiple consecutive spaces in the input string to a single space.
# Removing extra spaces
df['cleaned']=df['cleaned'].apply(lambda x: re.sub(' +',' ',x))
Removal of stopwords and lemmatization¶
The removal of stopwords and lemmatization are common techniques used in natural language processing to preprocess text data for analysis.
Stopwords are words that occur frequently in a language but do not carry much meaning on their own (e.g., “the”, “a”, “an”, “in”, etc.). Removing stopwords from text data can reduce noise and improve the quality of analysis.
Lemmatization is the process of reducing words to their base form (called the “lemma”), which can help to group together variations of the same word (e.g., “run”, “running”, “ran” are all reduced to the lemma “run”). This can reduce the vocabulary size and improve the accuracy of analysis. We’ll use SpaCy for the removal of stopwords and lemmatization.
# Importing spacy
import spacy
spacy.cli.download("en_core_web_sm")
from spacy import displacy
#nlp = spacy.load('en_core_web_sm')
# Loading model
nlp = spacy.load('en_core_web_sm',disable=['parser', 'ner'])
✔ Download and installation successful
You can now load the package via spacy.load('en_core_web_sm')
# Lemmatization with stopwords removal
df['cleaned']=df['cleaned'].apply(lambda x: ' '.join([token.lemma_ for token in list(nlp(x)) if (token.is_stop==False)]))
EXTRACT ONLY ADJECTIVES¶
This function extract_adjectives() takes a string of text as input, tokenizes the text into individual words, tags the parts of speech for each word using the NLTK’s POS tagger, extracts the adjectives from the tagged text, and returns a string of adjectives separated by spaces.
- The input text is tokenized into individual words using the word_tokenize() function from the NLTK library.
- The NLTK’s POS tagger is used to tag the parts of speech for each word in the text. This is done using the pos_tag() function from the NLTK library. The output of this function is a list of tuples, where each tuple contains a word and its associated part of speech tag.
- The adjectives are extracted from the tagged text by iterating over the list of tuples and selecting only those words that have a part of speech tag that starts with ‘JJ’ (which indicates an adjective). The selected words are then joined together into a single string separated by spaces using the join() function.
- Finally, the function returns the string of adjectives.
import nltk
from nltk.tokenize import word_tokenize
nltk.download('averaged_perceptron_tagger')
[nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\d\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date!
True
def extract_adjectives(text):
# Tokenize the text into individual words
words = word_tokenize(text)
# Use NLTK's POS tagger to tag the parts of speech for each word
pos_tags = nltk.pos_tag(words)
# Extract the adjectives from the tagged text and join them with commas
adjectives = " ".join([word for word, pos in pos_tags if pos.startswith('JJ')])
return adjectives
# Apply the function to the 'clean' column
df['adjectives'] = df['cleaned'].apply(extract_adjectives)
10 Random reviews after Removal of Punctuations and Numbers¶
# lets show the 10 random Reviews after Removal of Punctuations and Numbers
df['cleaned'].sample(10)
26 d deep cleaning service provide high quality e... 37 nocomment 29 communication good clean thorough complication... 32 nocomment 36 nocomment 47 nocomment 14 thorough cleaning carpet francis wonderful job... 46 nocomment 24 d deep cleaning service provide high quality e... 23 francis come clean place great place look grea... Name: cleaned, dtype: object
SENTIMENT ANALYSIS¶
Sentiment analysis is the analysis of how much a piece of text is positive and opinionated.
Here, in this case, checking only the polarity, i.e., how much a text is positive or negative, is sufficient. We can check the polarity of a review using the TextBlob library in Python:
This code imports the TextBlob library and calculates the polarity value for each row of the ‘cleaned’ column in the DataFrame.
The TextBlob class is a part of the textblob library, which is a Python library for processing textual data. It provides various natural language processing tools, such as sentiment analysis, part-of-speech tagging, and noun phrase extraction.
# Lets calculate the Polarity of the Reviews
from textblob import TextBlob
df['polarity']=df['cleaned'].apply(lambda x:TextBlob(x).sentiment.polarity)
#df['polarity']
#Assign Sentiment text
def get_polarity(text):
textblob = TextBlob(str(text))
pol = textblob.sentiment.polarity
if(pol>=0 and pol<=0.07):
return "Not fully satisfied"
elif(pol>0.07 and pol<=0.6):
return "Satisfied"
elif(pol>0.6 and pol<=1):
return "Very Satisfied"
elif(pol>-0.6 and pol<=0):
return "Not_Satisfied"
elif(pol>-1 and pol<=-0.6):
return "Awful"
df['comment_sentiment'] = df['cleaned'].apply(get_polarity)
Text Subjectivity¶
In natural language, subjectivity refers to expression of opinions, evaluations, feelings, and speculations and thus incorporates sentiment. Subjective text is further classified with sentiment or polarity.
# Lets calculate the Subjectvity of the Reviews
def get_subjectivity(text):
textblob = TextBlob(str(text.encode('utf-8')))
subj = textblob.sentiment.subjectivity
return subj
# lets apply the Function
df['subjectivity'] = df['cleaned'].apply(get_subjectivity)
#Adding rating sentiment features to the dataframe.
df["rating_sentiment"] = df["ratings"].apply(lambda score: "positive" if score > 3 else \
("negative" if score < 3 else "neutral"))
# calculating the Character Count in the Reviews
df['char_count'] = df['cleaned'].apply(len)
# calculating the Word Count
df['word_count'] = df['cleaned'].apply(lambda x: len(x.split()))
READING TIME¶
import textstat
df['reading_time'] = df['cleaned'].apply(lambda x: textstat.reading_time(x))
#df_sent['reading_time'] = df_sent['cleaned'].apply(lambda x: textstat.reading_time(x))
VISUALIZATION AND REPORTING¶
For reporting purpose we will create another dataset which contains reviews only
# create a boolean mask for rows that contain 'nocomment' in the text column
mask = df['cleaned'].str.contains('nocomment')
# use the mask to filter out rows that contain 'nocomment'
df_sent = df[~mask]
df.head(5)
name | ratings | user_tot_reviews | review_time_period | text | review_liked | response | days_since_reponse | response_text | cleaned | adjectives | polarity | comment_sentiment | subjectivity | rating_sentiment | char_count | word_count | reading_time | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 | 90 | Excellent service. Very professional and extre… | no | Response from the owner | 90 | Thanks for your feedback Mordi. | excellent service professional extremely court… | excellent professional courteous come carpet c… | 0.613333 | Very Satisfied | 0.760000 | positive | 104 | 13 | 1.35 |
1 | Barbara McHardy | 5 | 2 | 60 | Excellent used this company twice the first ti… | no | Response from the owner | 60 | thanks for your feedback Barbara. | excellent company twice time carpet clean day … | excellent carpet clean kitchen clean attend ba… | 0.483333 | Satisfied | 0.825000 | positive | 133 | 19 | 1.69 |
2 | Terri Ho | 5 | 3 | 210 | Used the end of tenancy cleaning and carpet an… | no | Response from the owner | 210 | Thanks for your feedback Terri. | end tenancy cleaning carpet sofa cleaning july… | efficient professional finish flat | 0.147222 | Satisfied | 0.308333 | positive | 139 | 19 | 1.78 |
3 | Nasima | 4 | 4 | 90 | they were very good but missed some cleaning i… | yes | Response from the owner | 90 | Thanks for your feedback Nasima. | good miss cleaning instruction bathroom get le… | good follow | 0.700000 | Very Satisfied | 0.600000 | positive | 130 | 18 | 1.66 |
4 | Alpha Connections | 2 | 2 | 365 | We booked a deep clean of our house. The staff… | no | Response from the owner | 330 | Hi,\nwe are very sorry to hear this from you. … | book deep clean house staff arrive experience … | deep clean arrive cleaner hard | 0.025000 | Not fully satisfied | 0.547222 | negative | 110 | 19 | 1.35 |
df_sent.head(5)
name | ratings | user_tot_reviews | review_time_period | text | review_liked | response | days_since_reponse | response_text | cleaned | adjectives | polarity | comment_sentiment | subjectivity | rating_sentiment | char_count | word_count | reading_time | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Wole Mordi | 5 | 2 | 90 | Excellent service. Very professional and extre… | no | Response from the owner | 90 | Thanks for your feedback Mordi. | excellent service professional extremely court… | excellent professional courteous come carpet c… | 0.613333 | Very Satisfied | 0.760000 | positive | 104 | 13 | 1.35 |
1 | Barbara McHardy | 5 | 2 | 60 | Excellent used this company twice the first ti… | no | Response from the owner | 60 | thanks for your feedback Barbara. | excellent company twice time carpet clean day … | excellent carpet clean kitchen clean attend ba… | 0.483333 | Satisfied | 0.825000 | positive | 133 | 19 | 1.69 |
2 | Terri Ho | 5 | 3 | 210 | Used the end of tenancy cleaning and carpet an… | no | Response from the owner | 210 | Thanks for your feedback Terri. | end tenancy cleaning carpet sofa cleaning july… | efficient professional finish flat | 0.147222 | Satisfied | 0.308333 | positive | 139 | 19 | 1.78 |
3 | Nasima | 4 | 4 | 90 | they were very good but missed some cleaning i… | yes | Response from the owner | 90 | Thanks for your feedback Nasima. | good miss cleaning instruction bathroom get le… | good follow | 0.700000 | Very Satisfied | 0.600000 | positive | 130 | 18 | 1.66 |
4 | Alpha Connections | 2 | 2 | 365 | We booked a deep clean of our house. The staff… | no | Response from the owner | 330 | Hi,\nwe are very sorry to hear this from you. … | book deep clean house staff arrive experience … | deep clean arrive cleaner hard | 0.025000 | Not fully satisfied | 0.547222 | negative | 110 | 19 | 1.35 |
Create a Document Term Matrix.¶
# Creating Document Term Matrix
from sklearn.feature_extraction.text import CountVectorizer
# Create a document-term matrix using CountVectorizer:
cv = CountVectorizer()
data = cv.fit_transform(df_sent['cleaned'])
df_dtm = pd.DataFrame(data.toarray(), columns=cv.get_feature_names())
df_dtm.index = df_sent['ratings']
C:\Users\d\anaconda3\lib\site-packages\sklearn\utils\deprecation.py:87: FutureWarning: Function get_feature_names is deprecated; get_feature_names is deprecated in 1.0 and will be removed in 1.2. Please use get_feature_names_out instead. warnings.warn(msg, category=FutureWarning)
df_dtm
absolutely | accordingly | advance | agency | agent | amazed | amazing | apartment | arrive | assess | attend | availability | available | awesome | barbara | bathroom | bedroom | bit | book | builder | building | call | calm | care | carpet | chuff | clean | cleaner | cleaning | cleanmidtenancy | colleague | come | communication | company | complication | courteous | crew | customer | day | ddeep | deal | deep | definitely | dennis | detail | dusty | easy | efficient | end | estate | excellent | excellently | expect | experience | extremely | fabulous | find | finish | flat | follow | francis | friend | fully | get | gleam | go | good | great | grimey | guy | hard | help | high | highly | highquality | hire | honestly | hope | hour | house | impressed | impressive | incredible | incredibly | instruction | job | july | kitchen | know | leave | let | level | look | lot | lovely | man | manage | manchester | mchardy | message | million | minute | miss | money | move | need | new | nice | non | notice | outand | outcome | oven | people | person | place | please | pleased | polite | possible | pre | preagreed | price | process | professional | property | provide | punctual | quality | quote | raymond | recommend | regular | require | responsive | satisfied | save | scrub | sell | sense | seriously | service | shabby | shine | short | sofa | space | sparkle | spend | spot | spring | staff | stop | straightforward | super | tailor | team | tenancy | thank | thorough | time | transparent | try | turn | twice | underneath | unit | use | visit | waste | window | wonderful | work | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ratings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 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ows to include only rating 5:
df_rating5 = df_dtm.loc[5]
# Get the top 10 most frequent words:
top_word5 = df_rating5.sum().sort_values(ascending=False)[:10]
df_rating5.head(5)
absolutely | accordingly | advance | agency | agent | amazed | amazing | apartment | arrive | assess | attend | availability | available | awesome | barbara | bathroom | bedroom | bit | book | builder | building | call | calm | care | carpet | chuff | clean | cleaner | cleaning | cleanmidtenancy | colleague | come | communication | company | complication | courteous | crew | customer | day | ddeep | deal | deep | definitely | dennis | detail | dusty | easy | efficient | end | estate | excellent | excellently | expect | experience | extremely | fabulous | find | finish | flat | follow | francis | friend | fully | get | gleam | go | good | great | grimey | guy | hard | help | high | highly | highquality | hire | honestly | hope | hour | house | impressed | impressive | incredible | incredibly | instruction | job | july | kitchen | know | leave | let | level | look | lot | lovely | man | manage | manchester | mchardy | message | million | minute | miss | money | move | need | new | nice | non | notice | outand | outcome | oven | people | person | place | please | pleased | polite | possible | pre | preagreed | price | process | professional | property | provide | punctual | quality | quote | raymond | recommend | regular | require | responsive | satisfied | save | scrub | sell | sense | seriously | service | shabby | shine | short | sofa | space | sparkle | spend | spot | spring | staff | stop | straightforward | super | tailor | team | tenancy | thank | thorough | time | transparent | try | turn | twice | underneath | unit | use | visit | waste | window | wonderful | work | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ratings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||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0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
top_word5
clean 20 service 19 cleaning 16 recommend 14 job 12 house 11 deep 10 professional 9 end 8 time 8 dtype: int64
# Create a bar plot of the top 10 most frequent words:
plt.figure(figsize=(20, 10))
plt.bar(top_word5.index, top_word5.values)
plt.title("Top 10 Most Frequent Words with Rating 5")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.xticks(rotation=45)
plt.show()
BAR PLOT FOR THE TOP 10 MOST FREQUENT WORDS WITH 4 STAR REVIEW¶
# Group the index by ratings:
grouped = df_dtm.groupby(level=0).sum()
grouped
absolutely | accordingly | advance | agency | agent | amazed | amazing | apartment | arrive | assess | attend | availability | available | awesome | barbara | bathroom | bedroom | bit | book | builder | building | call | calm | care | carpet | chuff | clean | cleaner | cleaning | cleanmidtenancy | colleague | come | communication | company | complication | courteous | crew | customer | day | ddeep | deal | deep | definitely | dennis | detail | dusty | easy | efficient | end | estate | excellent | excellently | expect | experience | extremely | fabulous | find | finish | flat | follow | francis | friend | fully | get | gleam | go | good | great | grimey | guy | hard | help | high | highly | highquality | hire | honestly | hope | hour | house | impressed | impressive | incredible | incredibly | instruction | job | july | kitchen | know | leave | let | level | look | lot | lovely | man | manage | manchester | mchardy | message | million | minute | miss | money | move | need | new | nice | non | notice | outand | outcome | oven | people | person | place | please | pleased | polite | possible | pre | preagreed | price | process | professional | property | provide | punctual | quality | quote | raymond | recommend | regular | require | responsive | satisfied | save | scrub | sell | sense | seriously | service | shabby | shine | short | sofa | space | sparkle | spend | spot | spring | staff | stop | straightforward | super | tailor | team | tenancy | thank | thorough | time | transparent | try | turn | twice | underneath | unit | use | visit | waste | window | wonderful | work | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ratings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 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| 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
5 | 3 | 1 | 1 | 1 | 1 | 1 | 4 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 4 | 1 | 20 | 0 | 16 | 1 | 1 | 5 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 10 | 2 | 6 | 1 | 1 | 1 | 4 | 8 | 1 | 5 | 1 | 1 | 1 | 4 | 1 | 1 | 2 | 1 | 0 | 2 | 1 | 1 | 0 | 1 | 1 | 4 | 6 | 1 | 2 | 3 | 2 | 2 | 7 | 1 | 1 | 1 | 0 | 2 | 11 | 2 | 1 | 1 | 2 | 0 | 12 | 1 | 3 | 1 | 3 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 2 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 4 | 1 | 1 | 1 | 3 | 0 | 1 | 1 | 1 | 1 | 2 | 1 | 1 | 3 | 1 | 1 | 1 | 2 | 1 | 9 | 2 | 2 | 1 | 2 | 1 | 1 | 14 | 1 | 2 | 2 | 1 | 1 | 1 | 1 | 0 | 1 | 19 | 0 | 1 | 3 | 1 | 1 | 2 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 7 | 7 | 7 | 8 | 1 | 0 | 2 | 1 | 0 | 0 | 3 | 1 | 1 | 1 | 1 | 5 |
# Filter the rows to include only rating 4:
df_rating4 = grouped.loc[4]
top_word4=df_rating4.sort_values(ascending=False)[:10]
# Create a bar plot of the top 10 most frequent words:
plt.figure(figsize=(20, 10))
plt.bar(top_word4.index, top_word4.values)
plt.title("Top 10 Most Frequent Words with Rating 4")
plt.xlabel("Words")
plt.ylabel("Frequency")
plt.xticks(rotation=45)
plt.show()