Basic sentiment analysis using python pandas
#python #pandas #dwbiadda #analysis #repeatedwords
import pandas as pd
alexa_data=pd.read_csv('C:\Data_Set\conv_data\Alexa_rating.csv')
alexa_data.head(6)
alexa_data['desc_conver'] = alexa_data.verified_reviews.str.lower().str.strip().str.split()
alexa_data.head()
stop_words = frozenset(['the', 'as', 'is','i','it','to','and','my','this','for','have','a','but','of','on','in','that','was','so','can','you'])
conv_list_reviews = list()
for data in alexa_data[['variation', 'desc_conver']].iterrows() :
row_data = data[1]
for final_word in row_data.desc_conver:
if final_word not in stop_words:
conv_list_reviews.append((row_data.variation, final_word))
verified_reviews = pd.DataFrame(conv_list_reviews, columns=['produc_type', 'Repeated_word'])
data_set=verified_reviews[verified_reviews.Repeated_word.str.len()>0]
data_set=data_set.groupby('produc_type').Repeated_word.value_counts().to_frame().rename(columns={'Repeated_word':'Cnt_of_word'})
data_set.head()
def display_top_rec(records, index_lvl=0):
final_result = records.groupby(level=index_lvl).apply(lambda records: records.nlargest(3,keep='first')).reset_index(level=index_lvl, drop=True)
return final_result.to_frame()
display_top_rec(data_set['Cnt_of_word'])