<jupyter_start><jupyter_text>code<jupyter_code>import sys
import os
import pymongo 
from pymongo import MongoClient
import pprint
mongodb_host='localhost'
mongodb_port='27017'
client = MongoClient ('mongodb://localhost:27017/')
db=client['db']
c1=db.pp2_0<jupyter_output><empty_output><jupyter_text>We got data from Twitter API.  In Python, we created a list for 3 tags, which are 3 football players' name.  And we used Twitter API  with  Python code to get the related data. 1. What are people saying about me (somebody)?    Because the data we scrapied is about three tags.  For this question,  we used  Mongodb to get all the data in dataset. They are alll related the tags. So they can completely explain what are people saying about me.<jupyter_code>for post in db.pp2_0.find({}):
    pprint.pprint(post)<jupyter_output>{'_id': ObjectId('5ada83078a17cf7c30efc735'),
 'create_time': '14:28:06',
 'favourites_count': 760,
 'followers_count': 62,
 'friends_count': 791,
 'id': 981176520109535000,
 'lang': 'en',
 'listed_count': 1,
 'location': 'null',
 'retweet_count': 500,
 'screen_name': 'ChukwumaEjike2',
 'statuses_count': 1108,
 'text': "RT @MESSlSTATS_: L<NAME>'s goal vs Sevilla means he has now "
         'scored 21 La Liga goals as a substitute',
 'time_zone': 'null',
 'url': 'null'}
{'_id': ObjectId('5ada83078a17cf7c30efc736'),
 'create_time': '14:28:05',
 'favourites_count': 14,
 'followers_count': 9,
 'friends_count': 30,
 'id': 981176517500833000,
 'lang': 'pt',
 'listed_count': 0,
 'location': 'Rio de Janeiro  Brasil',
 'retweet_count': 11,
 'screen_name': 'RafaelBdS89',
 'statuses_count': 136,
 'text': '@lucasgagliardis @gabrebustamante @AnaReis221 @JuniorB90987368 '
         '@Thiagofbpa @Gremio @GremioFuture @Flamengo Ganso le\\u2026 '
         'https:\\/\\/t.co\\/89PCo0AXXy',
 'time_zon[...]<jupyter_text>2. How viral are my posts?   We suppose that the retweet number an reflect how viral of every post. So in this query,  we ordered the retweet count in Mongodb to show all posts virality. And then just show users screen_name and its related retweet number.<jupyter_code>for post in db.pp2_0.find({},{'_id':0,'screen_name':1,'retweet_count':1,}).sort('retweet_count',-1):
    pprint.pprint(post)<jupyter_output>{'retweet_count': 54345, 'screen_name': 'pecos1998'}
{'retweet_count': 6754, 'screen_name': 'bgirlthai'}
{'retweet_count': 6642, 'screen_name': 'PrinceBled'}
{'retweet_count': 6576, 'screen_name': 'Martiwolflove'}
{'retweet_count': 6576, 'screen_name': 'NandaLirio'}
{'retweet_count': 6574, 'screen_name': 'LuciaPerezz9'}
{'retweet_count': 6562, 'screen_name': 'FHGTIPS'}
{'retweet_count': 6523, 'screen_name': 'iryna_ferreira'}
{'retweet_count': 6461, 'screen_name': 'dolovanduriez1'}
{'retweet_count': 5675, 'screen_name': 'gutiman23'}
{'retweet_count': 5674, 'screen_name': 'Gordo9020'}
{'retweet_count': 5643, 'screen_name': 'imtheooo'}
{'retweet_count': 5621, 'screen_name': 'Kelvin97168783'}
{'retweet_count': 5621, 'screen_name': 'ZheeOmega'}
{'retweet_count': 5542, 'screen_name': 'Nolbun'}
{'retweet_count': 5532, 'screen_name': 'M_Resendez10'}
{'retweet_count': 5465, 'screen_name': 'goalz24'}
{'retweet_count': 5464, 'screen_name': '_RubiaGabriella'}
{'retweet_count': 5463, 'screen_name':[...]<jupyter_text>3. What topics are trending in my domain?   Because the list we created to scrapied the data is in three name. In this question, we filtered  the name of  each one in the list and constrained in one same minute like 14:28 to count which one has the most tweets. From the outcome below, we can conclude <NAME> is most trending.<jupyter_code>db.pp2_0.find({'$and':[{'create_time':{'$regex': '14:28'}},{'text':{'$regex':'<NAME>'}}]}).count()
db.pp2_0.find({'$and':[{'create_time':{'$regex':'14:28'}},{'text':{'$regex':'<NAME>'}}]}).count()
db.pp2_0.find({'$and':[{'create_time':{'$regex':'14:28'}},{'text':{'$regex':'Neymar'}}]}).count()<jupyter_output><empty_output><jupyter_text>4. What posts are like mine?   In this question, we assume people with same tags are like others. So, we randomly selected one like '<NAME>'.  And we get the user  screen_name and text of users who posted tags in '<NAME>'.<jupyter_code>for post in db.pp2_0.find({'text':{'$regex':'<NAME>'}},{'screen_name':1,'_id':0,'text':1}):
  pprint.pprint(post)<jupyter_output>{'screen_name': 'FinnWonderland',
 'text': 'RT @ChampionsLeague: .@C<NAME> has scored 2\\u20e32\\u20e3 '
         'goals in his last 1\\u20e33\\u20e3 UEFA Champions League '
         'appearances!\\n\\nBacking him to score to\\u2026'}
{'screen_name': '_ricardofcsilva',
 'text': 'RT @_rubendaniel_: Qual o melhor do mundo?\\ud83c\\udf0d\\n\\nRt- '
         '<NAME>\\nFav- <NAME> https:\\/\\/t.co\\/EYeVsX8BSO'}
{'screen_name': 'cesar_bortolini',
 'text': 'RT @Grande_Area: \\Como se defender contra <NAME>? '
         'N\\u00e3o d\\u00ea espa\\u00e7o e n\\u00e3o o deixe cortar para a '
         'direita. Como se defender contra Mes\\u2026"'}
{'screen_name': 'mathis_arj',
 'text': 'RT @Zack_Nani: Bonjour bonjour mes bros vous voulez gagner de '
         'l\\u2019argent facilement ? <NAME> a fait ses petites '
         'm\\u00e8ches caramel eff\\u2026'}
{'screen_name': 'Illegal_Fructis',
 'text': 'RT @Butecodt: Hoje tem Buffon x <NAME>[...]<jupyter_text>5.What users post like me?   In this question, we assume people with same tags are like others. For example, people posted with '<NAME>' tags are like others. Then we get their id and screen_name.<jupyter_code>for post in db.pp2_0.find({'text':{'$regex':'<NAME>'}},{'id':1,'screen_name':1, '_id':0}):
  pprint.pprint(post)<jupyter_output>{'id': 981176525138489000, 'screen_name': 'FinnWonderland'}
{'id': 981176535393689000, 'screen_name': '_ricardofcsilva'}
{'id': 981176581002588000, 'screen_name': 'cesar_bortolini'}
{'id': 981176581690404000, 'screen_name': 'mathis_arj'}
{'id': 981176585150697000, 'screen_name': 'Illegal_Fructis'}
{'id': 981176599222673000, 'screen_name': 'Rogelio63381911'}
{'id': 981176621926412000, 'screen_name': 'Matheus_Sbrussi'}
{'id': 981176627202752000, 'screen_name': 'PickPosts'}
{'id': 981176644227551000, 'screen_name': 'PrinceBled'}
{'id': 981176657657544000, 'screen_name': 'izwansharii_'}
{'id': 981176672492769000, 'screen_name': 'Anthonyy2_'}
{'id': 981176674606833000, 'screen_name': 'Kelvin97168783'}
{'id': 981176691660873000, 'screen_name': 'imtheooo'}
{'id': 981176691845410000, 'screen_name': 'M_Resendez10'}
{'id': 981176701001617000, 'screen_name': 'FHGTIPS'}
{'id': 981176732853051000, 'screen_name': 'qvivaeldeporte'}
{'id': 981176757289213000, 'screen_name': 'KwiffOfficial'}
{'id': 981[...]<jupyter_text>6. Who should I be following?    We assume user we searched in API were all taged in '<NAME>'.   And we think they are likely to follow people  with the a great amont of  followers count. So we put them in a descending order to see which one they are most interested in following.<jupyter_code>for post in db.pp2_0.find({'text':{'$regex':'<NAME>'}},{'screen_name':1,'followers_count':1, '_id':0}).sort('followers_count',-1):
  pprint.pprint(post)<jupyter_output>{'followers_count': 191825, 'screen_name': 'yurtgazetesi'}
{'followers_count': 141683, 'screen_name': 'TheCristianoFan'}
{'followers_count': 90878, 'screen_name': 'Radioestadio'}
{'followers_count': 24406, 'screen_name': 'LenonMoura10'}
{'followers_count': 10422, 'screen_name': 'AimSubedi'}
{'followers_count': 8967, 'screen_name': 'FHGTIPS'}
{'followers_count': 7610, 'screen_name': 'DonBalonRosa'}
{'followers_count': 6674, 'screen_name': 'KwiffOfficial'}
{'followers_count': 2042, 'screen_name': 'JVKlippel'}
{'followers_count': 1576, 'screen_name': 'papsine1on1'}
{'followers_count': 1535, 'screen_name': 'dremar666'}
{'followers_count': 810, 'screen_name': 'M_Resendez10'}
{'followers_count': 718, 'screen_name': 'smpitrnl_'}
{'followers_count': 563, 'screen_name': 'Martiwolflove'}
{'followers_count': 541, 'screen_name': 'daniel_pico1'}
{'followers_count': 531, 'screen_name': 'Matheus_Sbrussi'}
{'followers_count': 531, 'screen_name': 'Leozinlns'}
{'followers_count': 522, 'screen_name': 'cl[...]<jupyter_text>7. What keywords/ hashtags should I add to my post?   We count all the data in a same period of different names. We seperated it in three times, because we have three names. From the query below, we can get the 'CR' ,'LM', 'NM' names appeares 48, 10,14 times, respectively.<jupyter_code>db.pp2_0.find({'text':{'$regex':'<NAME>'}}).count()
db.pp2_0.find({'text':{'$regex':'<NAME>'}}).count()
db.pp2_0.find({'text':{'$regex':'Neymar'}}).count()<jupyter_output><empty_output><jupyter_text>8.How much influence to my posts have?   We assume that number of retweets would show how much influence one post have. So we used id, screen_name and retweet_counts to explain posts' influence and their related users.<jupyter_code>for post in db.pp2_0.find({'text':{'$regex':'<NAME>'}},{'id':1,'screen_name':1,'_id':0,'retweet_count':1}):
  pprint.pprint(post)<jupyter_output>{'id': 981176525138489000,
 'retweet_count': 3431,
 'screen_name': 'FinnWonderland'}
{'id': 981176535393689000,
 'retweet_count': 132,
 'screen_name': '_ricardofcsilva'}
{'id': 981176581002588000,
 'retweet_count': 1322,
 'screen_name': 'cesar_bortolini'}
{'id': 981176581690404000, 'retweet_count': 2131, 'screen_name': 'mathis_arj'}
{'id': 981176585150697000,
 'retweet_count': 3245,
 'screen_name': 'Illegal_Fructis'}
{'id': 981176599222673000,
 'retweet_count': 2132,
 'screen_name': 'Rogelio63381911'}
{'id': 981176621926412000,
 'retweet_count': 654,
 'screen_name': 'Matheus_Sbrussi'}
{'id': 981176627202752000, 'retweet_count': 1, 'screen_name': 'PickPosts'}
{'id': 981176644227551000, 'retweet_count': 6642, 'screen_name': 'PrinceBled'}
{'id': 981176657657544000, 'retweet_count': 651, 'screen_name': 'izwansharii_'}
{'id': 981176672492769000, 'retweet_count': 2356, 'screen_name': 'Anthonyy2_'}
{'id': 981176674606833000,
 'retweet_count': 5621,
 'screen_name': 'Kelvin97168783'}
{'id': 981[...]
StarcoderdataJupyterStructuredCleanDedup