Below is my final project.  The formatting may be a bit off- moving from Word doc. with specific formatting into Word Press format changed some settings.  Title page through to Python code- the link to my Jupyter Notebook Code and resulting data output follows.  Thanks for your feedback, and good luck on your own- I am happy to provide feedback and if you want to share ideas or resources let me know- meyersbc@vcu.edu.

 

 

An Analysis of Body Shaming on Twitter

Benjamin C. Meyers

SOCY 676- Digital Data Research Proposal

Instructor- Dr. Gina Longo

 May 2020

 

 

 

 

 

 

 

 

 

 

Table of Contents

Section I:  Abstract…………………………………………………………………….                          Page 3

Section II: Introduction ……………………………………………………………….                      Page 4

Section III: Research Question(s)  …………………………………………………….              Page 5

Section IV: Literature Review ………………………………………………………..                  Page 6

Section V: Thesis Statement ………………………………………………………….                  Page 12

Section VI: Methodology …………………………………………………………….                     Page 12

Section VII: Data …………………………………………………………………….                           Page 15

Section VIII: Next Steps ……………………………………………………………..                     Page 15

Reference(s) ………………………………………………………………………….                           Page 17

Appendix A: Jupyter Notebook Code ……………………………………………….          Page 18

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Abstract

The following research paper is an analysis of the phenomena of body shaming that occurs frequently in social media spaces- specifically for this study on Twitter.  Body shaming is not a recent phenomena but its prevalence due to digital methods of technology and communication is alarming considering the numbers of persons who can potentially be exposed to it.  This research is exploratory in nature and design, with a focus in determining if a relationship can be made between social media use- specifically Twitter, and body shaming.  Additionally, this research seeks to make general connections between social media use and body shaming, looking for connections between Twitter users who may be viewing hashtags associated with fitness and weight loss and inadvertently being exposed to body shaming.  The methodology used for data extraction from Twitter will be use of a Twitter API and Python’s subpackage Anaconda, with coding done specifically through Jupyter Notebook.  A cross-sectional extraction of data will be used, using a snapshot of what may occur on a given day in the Twitter environment and what level of body shaming a user may be exposed to.  The main purpose of this research is to provide a point in time analysis, with data to support a hypothesis that seeks to explain how one’s use of social media may have a positive association with exposure to body shaming.

 

 

 

 

 

 

Introduction

Body shaming, defined by the National Association of Anorexia Nervosa includes over criticism of one’s own appearance through comparison to another, face to face criticism of another’s appearance, and/or criticism of another’s appearance without their presence or knowledge (National Association of Anorexia Nervosa, 2020).  Body shaming has most likely been occurring throughout history but modern digital technology and communications have allowed body shaming to affect millions of people globally with well over 3 billion people using social media in 2019 (Kemp, 2019, Saiphoo, Vahedi, 2019, pp. 259).  The occurrence of body shaming is seemingly ubiquitous within social media spaces and it’s prevalence manifests itself in various disturbances within various populations of people.  Current research regarding social media’s impact on body image is limited compared to the massive amount of social media users.  Additionally, the vast majority of research covering how social media use affects one’s body image includes young females, according to Marengo, Longobardi, Settanni, 2018 “previous research on HVSM is scant and mainly focuses on female samples”.  Research that does extend beyond the young female population yields similar results- most noticeably that spaces in social media related to body image include disproportionate levels of body shaming and negative effects on viewers.   Highly-visible social media (HVSM) is a popular form of social media and when social media is linked to body image disturbance it is often in HVSM applications.  The central concern regarding exposure to body shaming in social media spaces is the correlating experiences of body image disturbances.   Body image disturbances and what is known as “thinspiration” may contribute to eating disorders and other unhealthy practices, all of which have been associated with content posted on Twitter and other social media sites (Lewallen, Behm-Morawitz, 2016, pp. 1).  “Thinspiration” images, and other body shaming on social media affect those most susceptible and lead to body image disturbances.  While young females show the most susceptibility, research has linked levels of media literacy as another contributing factor that applies to various demographic populations.  According to research conducted by Burnette, 2017,  “they displayed high media literacy, appreciation of differences, and confidence, strategies that appeared helpful in mitigating the potential negative association between social media exposure and body image”.  The current research shows positive associations between social media exposure to body shaming and related body image disturbances.  This research seeks to contribute to existing literature with the application of providing additional evidence for improving methods of reducing the prevalence of body image disturbances among social media users.

 

Research Question(s)

Research Question:

-Does the use of social media platforms such as Facebook, Instagram, Twitter, and others affect one’s exposure to body shaming?

Related Questions:

-If so, How does exposure to body shaming affect one’s own body image, and does the exposure and repeated exposure contribute to negative behaviors such as body image disturbances and unhealthy practices- eating disorders, poor dietary habits, over exercising, etc.

-If there is a positive association between social media use and body image disturbances, what can be done to mitigate these negative experiences that are affecting one’s health.

 

 

Literature Review

Importance of the Research

Current research shows that there is a positive association between the use of various forms of social media and body image disturbances.  The main contributing factor to this phenomena is two fold- One that social media platforms, especially those categorized as HVSM are relatively unrestricted and allow for virtually limitless content some of which includes body shaming.  Two-that there is an enormous volume of users and traffic on social media spaces with reports in 2013 as high as 73% of U.S. adults frequenting a minimum of one site and over 40% using more than one (Duggan and Smith 2014, Ansager, 2014, pp. 408).  The appeal of many social media sites in addition to real time engagement and ability to communicate with virtually anyone and anywhere, is the relatively uncensored nature of social media platforms.  While there are extreme examples of content being pulled from some sites, for the most part social media users can post uncensored content and there is no regulation on who can post, what they post, or qualifications needed to post.  Social media sites can be viewed as uncensored, online conversations that can and often do include content sharing such as pictures and videos.  Social media account users can search limitless topic areas and become exposed to any and all online conversations and content.  It is this feature of social media spaces that leads many users directly or indirectly seeking content related to body image to become exposed to body shaming.  For example a simple search on Twitter such as #bodyimage or #weightloss produces a mixed return of varying levels of what is categorized as body image with content that often contains tweets and retweets of a very derogatory nature.

 

Lack of Existing Research

A central problem in understanding the challenges associated with what can be done regarding exposure to body shaming on social media spaces and related levels of body disturbance and poor health habits is a lack of research that goes into understanding this phenomena.  While body image disturbances have been studied over several decades, the inclusion of social media platforms in this research has been scarce, according to Andsager, 2014, “Little published research to date however has examined whether and how social media use, specifically, may influence perceptions of physical ideals and how best to attain those”.  Partly because social media spaces by nature are open forums, and not regulated, it is unofficially understood by users that the social media sites can be viewed as  “anything goes”.  This leads to many users establishing a laissez faire approach to negative outcomes of social media use because many users think of it as a space where a person goes voluntarily and if a user is unhappy with what they are exposed to they can simply choose not to view.  This characteristic of social media platforms has downplayed the negative experiences brought on by social media use, including body shaming, and has reduced the exposure and need of research to combat this problem.  This lack of research, documented according to Burnette, 2017, “Social media appear to contribute to body dissatisfaction in adolescents, although few empirical studies exist” consequently results in increased exposure to some, and this problem will most likely persist as social media spaces continue to grow in popularity.  It seems as though there will need to be a bimodal shift in order to address the prevalence of body shaming and related body disturbances- both a greater awareness of its prevalence on social media spaces and regulation against it as well as a greater recognition among academic and other research communities that make it an issue that needs to be addressed.  As mentioned by researchers Holland, Fardouly, Tiggemann et al., “A small but growing body of literature supports this, suggesting that social media usage is associated with body dissatisfaction and negative mood”.

 

Use of Social Media

One of the key concerns regarding the exposure of individuals to body shaming on social media environments such as Twitter is that there is a massive amount of users.  This creates an environment where body shaming content can not only be started by many individuals using Twitter but that content can then be shared within networks which are sometimes hundreds to hundreds of thousands of users.  The prevalence of social media platforms continues to grow, according to Rounsefell, Gibson, Mclean, et. al., 2019, “Approximately 90% of young adults in Australia, and the United States, use SM platforms, the majority on a daily basis, either in a passive or active form”.  This statistic can be alarming when considering that each one of these users can potentially be influenced by content found on Twitter and other social media platforms.  The amount of social media users and the scope and reach of their networks is analogous to a superhighway, where data created by users can easily be shared, reshared, and even passed on to those outside of networks, potentially creating the growth of networks which may be producing and/or supporting body shaming.  Looked at in one way, social media networks can be seen as connections between friends and supporters, and as new friends and/or supporters are added they then become exposed to the groups content.  This sort of network is developed across many social media platforms, Twitter being one of those platforms that now has approximately 59 million users (Statista, 2020).  There has been an approach by some organizations that realize the value in understanding the dynamics of social media networks to use the networks as ways to facilitate spreading positive and useful messages to combat body shaming.  Research done by Rounsefell, Gibson, Mclean, et. al., 2019,  have shown that “Due to exponential growth in social media (SM) use over the last decade, nutrition and health professionals, government, and non-government health organisations (health professionals) try to leverage SM to reinforce healthy food choices and nutrition -related behaviours in young adults”.  This level of engagement by organizations will most likely be one of the main contributors to reducing instances of body disturbances related to social media use since the number of users is forecasted to increase and there seems to be little to no movement to regulate spaces and the content available to users.

Media Literacy

One method of responding to body disturbances experienced as a result of social media use is the encouragement of learning more about and implementing media literacy techniques and programs.  Those involved in research and creating solutions for body image disturbances from social media use have had to look beyond limiting social media use and the influence of uncensored content to more effective methods.  If users will not either reduce their social media use or take measures to limit their exposure to select content then media literacy training can help address aspects of body dissatisfaction by teaching critical and analytical skills (Ansager, 2014, pp. 407).  The volume of social media users and various demographics associated with them has influenced how media literacy training has been influenced.  A central question regarding media literacy has been which demographic to provide support to- is there a certain age demographic, are males or females more affected, do certain races experience body shaming more than others?  Existing research suggests that body shaming and related body disturbances are not equally distributed among social media users.  The target demographic for most media literacy efforts has been among young female populations, who through limited research has been shown to be the most affected and most available for success, according to McLean, Wertheim, Masters, & Paxton, 2017, Saiphoo, Vahedi, 2019,  “Further, a pilot test of a social media literacy program targeted at adolescent girls was found to be effective at reducing disordered eating symptoms, improving body image, and overall increasing skepticism about the images on social media”.  Although research does implement young females as the most susceptible group to body disturbances, it should be known that research that does include other demographic groups yields similar results.  A benefit to intervention in body image disturbances is that because various demographic groups show similar results from body image disturbance from social media that similar solutions can be implemented.  In summary, solutions involve similar approaches and implementation for various demographics including sex and age, as expressed by Lenhart, Purcell, Smith, & Zickuhr, 2010, and Lewallen, Behm-Morawitz, 2016, “Although some researchers believe media literacy should focus on younger audiences and heavier users of media, the findings of this study suggest that these efforts may be relevant and useful throughout the life span”.  Considering the relatively limited volume of research, combined with the variety of users of social media, and limited resources to understand body disturbances it may be beneficial to broaden the scope of demographics to contribute to more general findings, especially since findings are similar across various populations.

 

Body Image Disturbances and Eating Disorders

The main concern regarding social media users that are exposed to body shaming is the potential for developing varying levels of body disturbance which range from over exercising and poor eating habits to diagnosed eating disorders and depression.  The challenge for those seeking to understand this phenomena and reduce its prevalence is to understand who is most easily affected and attempt to understand as well the range of body image disturbances.  Body image disturbances negatively affect one’s quality of life as reported by Stice, 2002, and Ridolfi, Crowther, Myers, Ciesla, 2011, “Research has found that body dissatisfaction is associated with negative emotions, such as sadness, guilt, and shame; it may impact quality of life on a daily basis and it is a major risk factor for eating disorders”.  Body image disturbance for some is already a reality and the use of social media platforms becomes a catalyst for worsening conditions of body disturbances.  There is research that currently shows that those most affected by body shaming and the eventual experience with body image disturbance are female populations but this problem is experienced by various other populations as well, especially younger populations that frequent a variety of social media spaces- according to Marengo, Longobardi, Settanni, 2018, “As a result, adolescents trying to cope with these negative feelings are more at risk of being involved in unhealthy behaviors such as restrictive diet, excessive exercise, steroid or illicit drug consumption, excessive tanning etc”.  The conversations surrounding body disturbances vary based upon demographics but there is also evidence to support a very general population of social media users that may be affected.  The occurrence of body shaming and “idealized” bodies online has created issues with one’s level of comfort with their own body, regardless of demographic group.  There are several concerns surrounding body image disturbances but of greatest concern over health related issues is the development of eating disorders such as anorexia nervosa, bulimia, and others especially among young female populations (Brumberg, 1992).  Further research that can provide stronger associations between social media use and eating disorders will most likely be the most appropriate pathway to both increasing levels of media literacy across various populations, as well as providing the best argument for considering levels of regulation among social media platforms.

 

Thesis Statement

This research is most closely related to the Sociological theories Symbolic Interactionism and Social Learning Theory.  Based upon the application of this research and the related theories it can be expected that there will be a positive association between social media users on Twitter and exposure to body shaming, which may result in body image disturbances and other negatively associated behaviors.  Both Symbolic Interaction and Social Learning theories which focus on symbolic meaning and the formation of one’s self can be influenced by relationships they develop in social media spaces- consequently some users who are exposed to body shaming may have such negative experiences that they experience poor body image and other health related disturbances.

Related Hypothesis:

Exposure to highly visible social media environments lead to increased exposure to body shaming.

 

 

Methodology

 

Research Study Design and Procedures

Statement of the Problem

The use of social media spaces such as Twitter provide a platform for increased exposure to body shaming that may manifest in varying levels of body image disturbance, disorder eating,  and/or other unhealthy habits.

Research question(s):

Does the use of social media platforms such as Facebook, Instagram, Twitter, and others affect one’s exposure to body shaming?

Methodology

Research Design:

This research was exploratory and its design developed accordingly.  The goal of this exploratory research was to examine the social processes at work in the use of the social media platform Twitter, and corresponding levels of exposure to body shaming.  This research study was cross-sectional- data was collected from a single point in time to capture a snapshot of what content may be available to a Twitter user.  In order to collect enough data for appropriate data analysis, tweets from Jan. 01, 2020 up to the date of data extraction were examined with a target of 200 tweets.  Two twitter hashtags, #skinny and #loseweight,  were selected in this research, both chosen as possible hashtags a user interested in weight loss and/or health and fitness may either search for directly or come across indirectly.

 

Subjects for Study

There were no direct research participants for this project- participants were included only in the process of Tweet selection which was done by producing the first 200 tweets from 01-01-2020 moving forward.  The scope of this research project was to produce a snapshot of what level of content may be viewable by users on a given hashtag at some given point in time  Additional methodology is outside the scope of this project.

Data Collection

Data collection was performed using the programming language Python to extract Twitter data from two selected hashtags that a user may come across either directly or indirectly within content related to losing weight or getting in shape.  Appropriate importing of Python packages along with coding that allowed for extracting tweets from two pre-selected Twitter hashtags was used.  The programming approach was to use the two pre-selected Twitter pages and extract the first 200 tweets that occurred on each hashtag, starting from the date of 01-01-2020.  The data extraction process was run for both #skinny as well as for #losingweight.  This data extraction approach produced the first 200 tweets from both hashtags in order for appropriate data analysis to be performed.

Hypotheses:

 

Hypothesis 1:

Exposure to highly visible social media environments lead to increased exposure to body shaming.

 

 

Null Hypothesis:

H0- μ1 ≠ μ2

 

 

Conceptualization of Variables

Conceptualization of both the independent variable- exposure to highly visible social media content, and the dependent variable- content containing body shaming,  provide a framework for how both the independent and dependent variable will be operationalized.  The independent variable, highly visible social media (or HVSM)  can be defined for this research project as social media content that contains attractive content that is marketed and seen with high frequency.  The dependent variable, levels of body shaming, can be conceptually defined as the viewing of social media content that contains insulting and/or derogatory messages.  Operationalization of Variables

Independent variable- exposure to highly visible social media is defined by the occurrence of a tweet that is in response to an identified hashtag- for this research project the two identified hashtags are #skinny or #loseweight.

 

Dependent variable- body shaming for this research project will be defined as any tweet that is an original tweet or retweet that has a negative score associated with the tweet from sentiment analysis.

 

Expected Results

This research project should produce an exploratory analysis of body shaming that occurs on Twitter based upon the implementation of the Python programming procedures.  The independent and dependent variable are effectively defined to measure the result of what levels of body shaming occur in selected social media hashtags.  Execution of the Python programming produces results that show 200 tweets starting on the date of 01-01-2020 for both identified hashtags.  Utilizing the data produced from each hashtag data extraction, implementing a sentiment analysis on each and then supporting the sentiment analysis by plotting sentiment scores will illustrate sentiment analysis results.

 

Data

Data produced from the Python programming code is included in a separate file and the coding is found in the Appendix of the research project.

 

 

Next Steps

Analysis Methods

In order for the collected data to be useful towards evidence in support of the research hypothesis the following data analysis methods have been implemented:

  1. Sentiment Analysis- A sentiment analysis of the hashtags #skinny and #weightloss provides a source of tweets that can be analyzed for occurrences of body shaming through examination of sentiment scores.  Sentiment scores range from -1 to 1, with negative scores (-1 to 0) representing some level of negativity and related body shaming.  Scores of 0 up to 1 represent neutral tweets and positive tweets that do not include body shaming.
  2. Plotting Sentiment Analysis- Plotting individual sentiment scores for both #skinny and #weightloss show the trends in sentiment scores over time and provide an illustration of the frequency of negative, neutral, and positive tweets over time.  A basic determination can be made about the frequency of negative tweets and associated body shaming by examining the plot.  Also, a plot that includes both hashtags scores can compare the relative amounts of sentiment scores and provide an illustration for comparison and contrast.
  3. Evaluating Sentiment Analysis- Utilizing both the sentiment analysis and plotting of sentiment analysis allows for a more comprehensive approach to how body shaming occurs on highly visible social media.  Respective of each other, the analyses can form a one dimensional examination but together the analyses provide two forms of data extraction and analysis that can produce results that support the research hypothesis.

 

 

 

Reference(s):

 

Andsager, Julie. “Research Directions in Social Media and Body Image.” Sex Roles 71.11-12 (2014): 407-13. Web.

Burnette, C. Blair, Melissa A Kwitowski, and Suzanne E Mazzeo. ““I Don’t Need People to Tell Me I’m Pretty on Social Media:” A Qualitative Study of Social Media and Body Image in Early Adolescent Girls.” Body Image 23 (2017): 114-25. Web.

Fardouly, Jasmine, and Elise Holland. “Social Media Is Not Real Life: The Effect of Attaching Disclaimer-type Labels to Idealized Social Media Images on Women’s Body Image and Mood.” New Media & Society 20.11 (2018): 4311-328. Web.

GeeksforGeeks. (2020). Twitter sentiment analysis using python. Retrieved from https://www.geeksforgeeks.org/twitter-sentiment-analysis-using-python/

Lewallen, Jennifer, and Elizabeth Behm-Morawitz. “Pinterest or Thinterest?: Social Comparison and Body Image on Social Media.” Social Media Society 2.1 (2016): Social Media Society, 29 March 2016, Vol.2(1). Web.

Marengo, D., C. Longobardi, M.A Fabris, and M. Settanni. “Highly-visual Social Media and Internalizing Symptoms in Adolescence: The Mediating Role of Body Image Concerns.” Computers in Human Behavior 82 (2018): 63-69. Web.

National Association of Anorexia Nervosa. (2020). Body shaming. Retrieved from https://anad.org/education-and-awareness/body-image/body-image-articles/body-shaming/

Pepin, Genevieve, and Natalie Endresz. “Facebook, Instagram, Pinterest and Co.: Body Image and Social Media.” Journal of Eating Disorders 3.S1 (2015): Journal of Eating Disorders, 12/2015, Vol.3(S1). Web.

Perloff, Richard. “Social Media Effects on Young Women’s Body Image Concerns: Theoretical Perspectives and an Agenda for Research.” Sex Roles 71.11-12 (2014): 363-77. Web.

Ridolfi, Danielle, R. Myers, Taryn Crowther, and A. Ciesla. “Do Appearance Focused Cognitive Distortions Moderate the Relationship between Social Comparisons to Peers and Media Images and Body Image Disturbance?” Sex Roles65.7 (2011): 491-505. Web.

Rounsefell, Kim, Simone Gibson, Siân Mclean, Merran Blair, Annika Molenaar, Linda Brennan, Helen Truby, and Tracy A Mccaffrey. “Social Media, Body Image and Food Choices in Healthy Young Adults: A Mixed Methods Systematic Review.” Nutrition & Dietetics: The Journal of the Dietitians Association of Australia (2019): Nutrition & Dietetics: the Journal of the Dietitians Association of Australia, 03 October 2019. Web.

Saiphoo, Alyssa N, and Zahra Vahedi. “A Meta-analytic Review of the Relationship between Social Media Use and Body Image Disturbance.” Computers in Human Behavior 101 (2019): 259-75. Web.

Statista. (Feb., 2020). Leading Countries Based Upon Number of Twitter Users as of January 2020. Retrieved from https://www.statista.com/statistics/242606/number-of-active-twitter-users-in-selected-countries/

 

Appendix

Appendix A: Jupyter Notebook Code

In [1]:

import os

In [2]:

import tweepy as tw

In [3]:

from datetime import datetime

In [4]:

import matplotlib.pyplot as plt

In [5]:

conda install -c conda-forge tweepy

Collecting package metadata (current_repodata.json): done

Solving environment: done

 

# All requested packages already installed.

 

 

Note: you may need to restart the kernel to use updated packages.

In [6]:

import pandas as pd

import twitter

In [7]:

auth = tw.OAuthHandler(consumer_key=’3VzwNUA576D2BernnU3fDkrzw’, consumer_secret=’sEGjaUMy7sv5AETJisWNDbucEiN3unsZdBraH6LzRK8R0peQb6′)

auth.set_access_token(key=’1229838194725646337-lPkNiib85Gcpp9eyg8uTMeHaBAg2l4′, secret=’vtwhmozJVkFkWm578GGOEZ7doZUXXOVYwXq74K2ON8dte’)

api = tw.API(auth, wait_on_rate_limit=True)

api = twitter.Api(consumer_key=’3VzwNUA576D2BernnU3fDkrzw’, consumer_secret=’sEGjaUMy7sv5AETJisWNDbucEiN3unsZdBraH6LzRK8R0peQb6′, access_token_key=’1229838194725646337-lPkNiib85Gcpp9eyg8uTMeHaBAg2l4′, access_token_secret=’vtwhmozJVkFkWm578GGOEZ7doZUXXOVYwXq74K2ON8dte’)

In [8]:

search_words = “#beingskinny”

date_since = “2019-02-01″

count = 50

results = api.GetSearch(term=search_words, since=date_since, count=count)

In [9]:

tweets = tw.Cursor(api.search,

q=search_words,

lang=”en”,

since=date_since).items(count)

In [ ]:

results

In [10]:

from nltk.sentiment.vader import SentimentIntensityAnalyzer

api.CheckRateLimit(“www.twitter.com/home/”)

In [11]:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

 

# function to print sentiments

# of the sentence.

def sentiment_scores(sentence):

 

# Create a SentimentIntensityAnalyzer object.

sid_obj = SentimentIntensityAnalyzer()

 

# polarity_scores method of SentimentIntensityAnalyzer

# object gives a sentiment dictionary.

# which contains pos, neg, neu, and compound scores.

sentiment_dict = sid_obj.polarity_scores(sentence)

 

print(“Overall sentiment dictionary is : “, sentiment_dict)

print(“sentence was rated as “, sentiment_dict[‘neg’]*100, “% Negative”)

print(“sentence was rated as “, sentiment_dict[‘neu’]*100, “% Neutral”)

print(“sentence was rated as “, sentiment_dict[‘pos’]*100, “% Positive”)

 

print(“Sentence Overall Rated As”, end = ” “)

 

# decide sentiment as positive, negative and neutral

if sentiment_dict[‘compound’] >= 0.05 :

print(“Positive”)

dec=1

 

elif sentiment_dict[‘compound’] <= – 0.05 :

print(“Negative”)

dec=-1

 

else :

print(“Neutral”)

dec=0

return [sentiment_dict[“pos”],sentiment_dict[“neu”], sentiment_dict[“neg”], sentiment_dict[“compound”], dec]

In [ ]:

 

In [26]:

for tweet in tweets:

print(tweet.text, tweet.created_at, “\n”)

sentiment_scores(tweet.text)

print(“\n\n”)

 

 

In [27]:

def tweetanalyzer(query,date_since,count):

auth = tw.OAuthHandler(consumer_key=’3VzwNUA576D2BernnU3fDkrzw’, consumer_secret=’sEGjaUMy7sv5AETJisWNDbucEiN3unsZdBraH6LzRK8R0peQb6′)

auth.set_access_token(key=’1229838194725646337-lPkNiib85Gcpp9eyg8uTMeHaBAg2l4′, secret=’vtwhmozJVkFkWm578GGOEZ7doZUXXOVYwXq74K2ON8dte’)

api = tw.API(auth, wait_on_rate_limit=True)

tweets = tw.Cursor(api.search,

q=query,

lang=”en”,

since=date_since).items(count)

data={}

fmt=”%Y-%m-%d”

 

for tweet in tweets:

print(type(date_since))

if tweet.text in data :

if data[tweet.text][1] <tweet.created_at:

continue

print(tweet.text, tweet.created_at, “\n”)

scores=sentiment_scores(tweet.text)

print(“\n\n”)

data[tweet.text]=([(tweet.created_at-datetime.strptime(date_since, fmt)).total_seconds()/60] + scores, tweet.created_at)

 

return data

In [28]:

data=tweetanalyzer(“#skinny”, “2020-01-01”, 200)

 

In [29]:

print(data)

 

In [30]:

scores1 = pd.DataFrame([tweet[0] for tweet in sorted(data.values())])

print(scores1)

 

In [31]:

plt.plot(scores1[0], scores1[4], color = “red”)

 

In [32]:

data2=tweetanalyzer(“#loseweight”, “2020-01-01”, 200)

 

In [33]:

print(data2)

 

In [34]:

scores2 = pd.DataFrame([tweet[0] for tweet in sorted(data2.values())])

 

In [35]:

plt.plot(scores2[0], scores2[4], color = “blue”)

 

In [36]:

plt.plot(scores1[0], scores1[4], color = “red”)

plt.plot(scores2[0], scores2[4], color = “blue”)

plt.xlabel(‘Seconds’)

plt.ylabel(‘Sentiment’)

plt.title(‘Sentiment of Tweets’)

plt.legend((‘#skinny’, ‘#loseweight’))

plt.show()

 

______Below is my Jupyter Notebook Code and resulting data output. _____________________________________

SOCY676SENTIMENTANALYSIS_PLOTTING_FINALJupyterNotebook

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *