This file contains hidden or 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 |
This file contains hidden or 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) |
This file contains hidden or 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() |
This file contains hidden or 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() |
This file contains hidden or 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())) |
This file contains hidden or 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) |
This file contains hidden or 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() |
This file contains hidden or 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]) |
This file contains hidden or 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) |
This file contains hidden or 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