part one of next week's homework:
#creating verified & non verified user df
df_unverified = df[df['verified']==False]
df_verified = df[df['verified']==True]
#creating verified & non verified user sentiment analyses
import seaborn as sns
df['sentiment'] = df_unverified['Text1'].apply(lambda tweet: TextBlob(tweet).sentiment.polarity)
df['sentiment']=df['sentiment'].astype('float')
positive = df[df['sentiment']>0].count().astype(int)
negative = df[df['sentiment']<0].count().astype(int)
neutral = df[df['sentiment']==0].count().astype(int)
labels= ['positive','neutral','negative']
sizes = [positive[0],neutral[0],negative[0]]
colors=['lightgreen','grey','orange']
patches, texts, poop = plt.pie(sizes, colors=colors, startangle=90, autopct='%1.0f%%')
plt.legend(patches, labels, loc="best")
plt.title("How unverified users are reacting on #brexit by analyzing " + str(positive[0]+negative[0]+neutral[0]) + " tweets.")
plt.axis('equal')
plt.show()
plt.savefig('sentiment_analysis_unverified_users')
df['sentiment'] = df_verified['Text1'].apply(lambda tweet: TextBlob(tweet).sentiment.polarity)
df['sentiment']=df['sentiment'].astype('float')
positive = df[df['sentiment']>0].count().astype(int)
negative = df[df['sentiment']<0].count().astype(int)
neutral = df[df['sentiment']==0].count().astype(int)
labels= ['positive','neutral','negative']
sizes = [positive[0],neutral[0],negative[0]]
colors=['lightgreen','grey','orange']
patches, texts, poop = plt.pie(sizes, colors=colors, startangle=90, autopct='%1.0f%%')
plt.legend(patches, labels, loc="best")
plt.title("How verified users are reacting on #brexit by analyzing " + str(positive[0]+negative[0]+neutral[0]) + " tweets.")
plt.axis('equal')
plt.show()
plt.savefig('sentiment_analysis_verified_users')