twitterpersona.sentiment_analysis¶
Module Contents¶
Functions¶
|
Labelling each row in a given column of tweets/text with positive, negative or neutral sentiment. |
|
Count the proportion of different sentiment tweets in a labelled sentiment dataframe |
- twitterpersona.sentiment_analysis.sentiment_labler(df, col)[source]¶
Labelling each row in a given column of tweets/text with positive, negative or neutral sentiment.
- Parameters:
df (pd.DataFrame) – A dataframe that has been pre-processed.
col (str) – Column name of the column containing tweets in the dataset.
- Returns:
df – Dataframe contains all tweets the corresponding labels.
- Return type:
pd.DataFrame
Examples
sentiment_labler(df, “text”)
- twitterpersona.sentiment_analysis.count_tweets(df, proportion=True)[source]¶
Count the proportion of different sentiment tweets in a labelled sentiment dataframe
- Parameters:
df (pd.DataFrame) – dataframe for each sentiment
proportion (bool) – if True: returns the proportion; otherwise, return the counts.
- Returns:
A dictionary which calculates the proportion of three sentiments of tweets.
- Return type:
dictionary
Examples
labelled_df = sentiment_labler(df, “text”) count_tweets(labelled_df)