text_plain_output_1.png
from textblob import Word, TextBlob

from warnings import filterwarnings

from wordcloud import WordCloud

import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

filterwarnings('ignore')
pd.set_option('display.max_columns', None)
pd.set_option('display.width', 200)
pd.set_option('display.float_format', lambda x: '%.2f' % x)

df = pd.read_csv('../input/reviews/Restaurant_Reviews.tsv', delimiter='\t')

df.shape

drops = pd.Series(' '.join(df['Review']).split()).value_counts()[-250:]
df['Review'] = df['Review'].apply(lambda x: ' '.join((x for x in x.split() if x not in drops)))

df['Review'] = df['Review'].apply(lambda x: ' '.join([Word(word).lemmatize() for word in x.split()]))

tf = df['Review'].apply(lambda x: pd.value_counts(x.split(' '))).sum(axis=0).reset_index()

tf.columns = ['words', 'tf']

tf.shape

tf.sort_values('tf', ascending=False)

text = ' '.join((i for i in df.Review))
wordcloud = WordCloud().generate(text)
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()
wordcloud = WordCloud(max_font_size=50, max_words=100, background_color='white').generate(text)
plt.figure()
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()
wordcloud.to_file('wordcloud.png')