In the comings posts, I will be analyzing four key politicians around the world Prime Minister Narendra Modi, Congress Vice-President Rahul Gandhi, and Delhi Chief Minister Arvind Kejriwal from India; President Barrack Obama, Democratic candidate and Former Secretary of State Hillary Clinton, and Republican candidate and Business Tycoon Donald Trump from the US.

For the first leg of the analysis, I will be looking into what they tweet, when they tweet, what these tweets contains, how are the sentiment of these tweets, who are most common people tagged in these tweets, are the tweets abusive or are in praise, variation in number of Retweets/Favorite.

Let’s take a look at the profile of these politicians on Twitter.


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

Prime Minister Narendra Modi, India


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

Current President Barack Obama, USA


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

Democratic Presidential Candidate, Hillary Clinton


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

RepublicanPresidential Candidate,Donald Trump


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

New Delhi Chief Minister, Arvind Kejriwal


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

Indian National Congress Vice-President, Rahul Gandhi

Who has the maximum number of twitter followers and when did they join Twitter? Narendra Modi 12,800 tweets, 1433 following, 23.4 million followers, Joined January 2009 Barack Obama 15,300 tweets, 634,000following, 77.9 million followers, Joined March2007 Hillary Clinton 8,862 tweets, 758following, 9.57 million followers, Joined April2013 Donald Trump 33,500 tweets, 41following, 12.3 million followers, Joined March2009 Rahul Gandhi 2,321tweets,74following, 989,000followers, Joined April2015 Arvind Kejriwal 14,700 tweets, 159following, 9.34 million followers, Joined November2011 Observations Clearly, President Obama is in the lead when it comes to followers with 77.9 million followers. He was also the first among these politicians to understand the power of social media. He joined Twitter in March 2007, way ahead of everyone else. He is also quite generous in following people, following over 634,000 people. Prime Minister Modi commands the second largest following in this group, with over 23.4 million followers and follows over 1400 people. He also understood the social media and joined at an early stage. Hillary Clinton has around 9000 tweets and 9.57 million followers, although she joined in April 2013. Donald Trump Well you must have noticed the number of tweets, 33,500. Wow. He is clearly and outlier among these politicians. Moreover, he only follows 41 people. Clearly, he is choosy. Rahul Gandhi is among the newest to understand the power of social media and has less than a million followers with over 2300 tweets. Arvind Kejriwal has over 14000 tweets and 9 million followers and he joined Twitter in November 2011.

Let’s take a look at the above information in a table.

Name Tweets Followers Following Joined Date Today Months Since Joined Tweets Per Month Narendra Modi 12800 23400000 1433 Jan-09 Oct-16 93 138 Barack Obama 15300 77900000 634000 1-Mar Oct-16 115 133 Hillary Clinton 8862 9570000 758 Apr-13 Oct-16 42 211 Donald Trump 33500 12300000 41 Mar-09 Oct-16 91 368 Rahul Gandhi 2321 989000 74 Apr-15 Oct-16 18 129 Arvind Kejriwal 14700 9340000 159 Nov-11 Oct-16 59 249
Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

The figure above shows the number of tweets by politicians and we can see that Trump leads them on the top. The size of the bubble is the tweet per month, which again shows Trump leading. To make the above graph, save the table we talked before to a csv file. I saved as eda.csv. Let’s take a look at the code below that produces the figure.

importmatplotlib.pyplotas plt importpandasas pd ## read the csv file to a pandas dataframe df = pd.read_csv('eda.csv') ## initialize a subplot plt.subplots_adjust(bottom = 0.1) ## make a scatter plot with Number of tweets in the Y axis and size as the tweets per month plt.scatter( range(len(df['Name'])), df['Tweets'], marker = 'o', c = df['Tweets Per Month'], s = df['Tweets Per Month'], cmap = plt.get_cmap('Spectral')) ## annotate each bubble with the name of the politician for label, x, y in zip(df['Name'] , range(len(df['Name'])), df['Tweets']): plt.annotate( label, xy = (x, y), xytext = (-20, 20), textcoords = 'offset points', ha = 'right', va = 'bottom', bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5), arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')) ## add title and labels # Chart title plt.title('Number of Tweets by Politicians') # y label plt.ylabel('Number of Tweets') # and a legend plt.legend(loc='upper right') ## show the plot and save it plt.show() plt.savefig('number of tweets.png') A small modification in the code above will give us another bubble chart with number of tweets per month.
Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

We see a shift in some places, but Donald Trump is still leading on the top. We see Narendra Modi, Rahul Gandhi, and Barack Obama are among-st the one who tweet least among this group.

Let’s take a look at the followers and following on Twitter by these politicians.


Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine
Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine

President Obama is someone who lies as an outlier in both of them, with a staggering 77.9 million followers and by following 634,000 (he is too generous it looks like).

All that was to give an overall ideas on these politicians on Twitter. For the next part of this project, we would be analyzingthe tweets by these politicians in the last 5 months.

Familiarize with tweepy module in python : I have already written about this module before,here,here, andhere. I like using tweepy and I have done many projects in it. You can use other modules available. Get Twitter API Keys : To request data from Twitter, you need to have API keys. To start with, you will need to have a Twitter account and obtain credentials (i.e. API key, API secret, Access token and Access token secret) on the Twitter developer site to access the Twitter API, following these steps: Create a Twitter user account if you do not already have one.

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: MongoDBWindowsTwitterPython
分页:12
转载请注明
本文标题:Analyzing Key Politicians : Part(1) Setting up MongoDB on a Windows Machine
本站链接:http://www.codesec.net/view/481338.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(29)