View eta_on_text_data-1.py
This file contains 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 numpy as np | |
import pandas as pd | |
# For visualizations | |
import matplotlib.pyplot as plt | |
# For regular expressions | |
import re | |
# For handling string | |
import string | |
# For performing mathematical operations | |
import math |
View eta_on_text_data-2.py
This file contains 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
df=df[['name','reviews.text','reviews.doRecommend','reviews.numHelpful']] | |
print("Shape of data=>",df.shape) | |
df.head(5) |
View eta_on_text_data-3.py
This file contains 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
df.isnull().sum() |
View eta_on_text_data-4.py
This file contains 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
df.dropna(inplace=True) | |
df.isnull().sum() |
View eta_on_text_data-5.py
This file contains 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
df=df.groupby('name').filter(lambda x:len(x)>500).reset_index(drop=True) | |
print('Number of products=>',len(df['name'].unique())) |
View eta_on_text_data-6.py
This file contains 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
df['reviews.doRecommend']=df['reviews.doRecommend'].astype(int) | |
df['reviews.numHelpful']=df['reviews.numHelpful'].astype(int) |
View eta_on_text_data-7.py
This file contains 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
df['name'].unique() |
View eta_on_text_data-8.py
This file contains 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
df['name']=df['name'].apply(lambda x: x.split(',,,')[0]) |
View eta_on_text_data-9.py
This file contains 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
for index,text in enumerate(df['reviews.text'][35:40]): | |
print('Review %d:\n'%(index+1),text) |
View eta_on_text_data-10.py
This file contains 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
# 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", |
OlderNewer