From d001e6f087dad05fc326fef41deec0206520536f Mon Sep 17 00:00:00 2001 From: Nancy Sanchez Date: Sat, 2 Nov 2019 12:59:51 -0600 Subject: [PATCH 1/4] Avance a las 13:00 h --- .DS_Store | Bin 0 -> 6148 bytes your-code/API.ipynb | 151 ++++++++++++++++++++++++++++++ your-code/Scraping.ipynb | 194 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 .DS_Store create mode 100644 your-code/API.ipynb create mode 100644 your-code/Scraping.ipynb diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..12e37edb50b8759a9639c5f7657bced108dfb37e GIT binary patch literal 6148 zcmeHKO-jU23{J)_W^gl0-Sq+r;|a=8PcSQYLMx+SX_4u|-D7UxO+1QQLELx|zr2Lf z(snDN2_)ZZUh;mv4$Xv!c-xj6qBRjMp@NGQ%!J6i=tvgkkx7;{9`~DFQCH0<(jC8* z0eN=`UDBQ&=rDYL%~gM{s`I>T4+YWt*Ue|VPM25JZI0GF6 z@_k65f|+4ZjGqpe*a83(xT9b!y@ceXhM8ed#0-Qr6{x9fEe2~k{HeudhCxx&iLLoy z+nKFH;kY~2Ph&W7rs&oga0Z49oap0P>i_k8|36IfCuhJJ_)`pUlJD{@u4J`!bUCTD sDfAX9B5^^nOTi$PV#G=*K7&SqKa~M6GYpFGK>UwDq`{3d@S_ZT17*KR{r~^~ literal 0 HcmV?d00001 diff --git a/your-code/API.ipynb b/your-code/API.ipynb new file mode 100644 index 0000000..946bd2d --- /dev/null +++ b/your-code/API.ipynb @@ -0,0 +1,151 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "import requests\n", + "import pandas as pd\n", + "from pandas.io.json import json_normalize" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "url = 'https://content.guardianapis.com/search?section=culture&q=brexit&api-key=f2191338-37f5-44bc-bd53-2ef1ff8f7d98'" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [], + "source": [ + "brexit = requests.get(url).json()" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [], + "source": [ + "brexit = json_normalize(brexit)" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "results = brexit['response.results']\n", + "\n", + "info = [json_normalize(i) for i in results]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'webTitle'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2896\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2897\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2898\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'webTitle'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtitlesJson\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbrexit_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'webTitle'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mtitles_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mtitle\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mtitle\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtitlesJson\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mtitles_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2978\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2979\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2980\u001b[0;31m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2981\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2982\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2897\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2898\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2899\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2900\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2901\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'webTitle'" + ] + } + ], + "source": [ + "titlesJson = requests.get(brexit_data['webTitle']).json()\n", + "titles_list = [title for title in titlesJson]\n", + "titles_list" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'webTitle'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbrexit\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'webTitle'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m: 'webTitle'" + ] + } + ], + "source": [ + "brexit['webTitle']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/your-code/Scraping.ipynb b/your-code/Scraping.ipynb new file mode 100644 index 0000000..7b53a00 --- /dev/null +++ b/your-code/Scraping.ipynb @@ -0,0 +1,194 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import requests\n", + "from bs4 import BeautifulSoup\n", + "import pandas as pd\n", + "from pprint import pprint\n", + "from lxml import html\n", + "from lxml.html import fromstring\n", + "import urllib.request\n", + "from urllib.request import urlopen\n", + "import random\n", + "import re\n", + "import scrapy" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "url = 'https://www.imdb.com/title/tt0804503/'" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "soup = requests.get(url).content\n", + "soup = BeautifulSoup(soup,'html.parser')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Jon Hamm',\n", + " 'Elisabeth Moss',\n", + " 'Vincent Kartheiser',\n", + " 'January Jones',\n", + " 'Christina Hendricks',\n", + " 'Aaron Staton',\n", + " 'Rich Sommer',\n", + " 'John Slattery',\n", + " 'Kiernan Shipka',\n", + " 'Robert Morse',\n", + " 'Christopher Stanley',\n", + " 'Jessica Paré',\n", + " 'Jay R. Ferguson',\n", + " 'Michael Gladis',\n", + " 'Bryan Batt',\n", + " 'Alison Brie']" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Lista del casr\n", + "cast = soup.select(\"table.cast_list a[href^='/name']\")\n", + "names = [name.text for name in cast]\n", + "names = list(map(lambda x:x.strip(),repositories))\n", + "final_names = [text for text in names if len(text)>1]\n", + "final_names" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Don Draper',\n", + " 'Peggy Olson',\n", + " 'Pete Campbell',\n", + " 'Betty Francis',\n", + " 'Joan Harris',\n", + " 'Ken Cosgrove',\n", + " 'Harry Crane',\n", + " 'Roger Sterling',\n", + " 'Sally Draper',\n", + " 'Bertram Cooper',\n", + " 'Henry Francis',\n", + " 'Megan Draper',\n", + " 'Stan Rizzo',\n", + " 'Paul Kinsey',\n", + " 'Salvatore Romano',\n", + " 'Trudy Campbell']" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Lista de personajes\n", + "characters = soup.select(\"td.character a[href^='/title']\")\n", + "characters = [name.text for name in characters]\n", + "characters" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['92 episodes',\n", + " '92 episodes',\n", + " '92 episodes',\n", + " '92 episodes',\n", + " '92 episodes',\n", + " '92 episodes',\n", + " '92 episodes',\n", + " '89 episodes',\n", + " '89 episodes',\n", + " '74 episodes',\n", + " '54 episodes',\n", + " '49 episodes',\n", + " '46 episodes',\n", + " '40 episodes',\n", + " '39 episodes',\n", + " '38 episodes']" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Lista de episodios por personaje\n", + "episodes = soup.select(\"a.toggle-episodes\")\n", + "episodes = [episode.text for episode in episodes]\n", + "number_episodes = []\n", + "for i in episodes:\n", + " number_episodes.append(i.split(\",\")[0])\n", + "number_episodes\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "seasons = soup.select(\"div.seasons-and-year-nav a[href^='/title']\")\n", + "\n", + "characters = [name.text for name in characters]\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From a1a728da9d6693cd21b837722f63868a4484434c Mon Sep 17 00:00:00 2001 From: Nancy Sanchez Date: Sat, 2 Nov 2019 17:25:44 -0600 Subject: [PATCH 2/4] Avances hasta las 5:25 --- .DS_Store | Bin 6148 -> 6148 bytes your-code/API.ipynb | 1072 +++++++++++++++++++++++++++++++++++-- your-code/Scraping.ipynb | 136 ++++- your-code/Scraping2.ipynb | 166 ++++++ 4 files changed, 1317 insertions(+), 57 deletions(-) create mode 100644 your-code/Scraping2.ipynb diff --git a/.DS_Store b/.DS_Store index 12e37edb50b8759a9639c5f7657bced108dfb37e..1bcb28b850209a11ffa97ffe59f045f24155c26d 100644 GIT binary patch delta 134 zcmZoMXffEJ#$?f4!oa}5!l1{H&XCDalAG`1l2Tfd%)oH-ano|342oO|lHBAtCTS+7 zgvoE2#07HF4TF>Oa|^)g8GHXte#ay>c?S~@(}9c?S~@Q`5xBZ6T0 NnOMNLnVsV=KL7?=DAND{ diff --git a/your-code/API.ipynb b/your-code/API.ipynb index 946bd2d..09368b4 100644 --- a/your-code/API.ipynb +++ b/your-code/API.ipynb @@ -2,121 +2,1091 @@ "cells": [ { "cell_type": "code", - "execution_count": 44, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ "import json\n", "import requests\n", "import pandas as pd\n", - "from pandas.io.json import json_normalize" + "from pandas.io.json import json_normalize\n", + "import tweepy\n", + "import re \n", + "from tweepy import OAuthHandler \n", + "from textblob import TextBlob\n", + "from nltk.corpus import stopwords\n", + "import requests\n", + "from bs4 import BeautifulSoup\n", + "\n", + "#cursor\n", + "#tweet.text" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "url = 'https://www.imdb.com/chart/tvmeter?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=4da9d9a5-d299-43f2-9c53-f0efa18182cd&pf_rd_r=0KYJP3BJH5DN6EZWRQ5Z&pf_rd_s=right-4&pf_rd_t=15506&pf_rd_i=toptv&ref_=chttvtp_ql_5'" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ - "url = 'https://content.guardianapis.com/search?section=culture&q=brexit&api-key=f2191338-37f5-44bc-bd53-2ef1ff8f7d98'" + "soup = requests.get(url).content\n", + "soup = BeautifulSoup(soup,'html.parser')" ] }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ - "brexit = requests.get(url).json()" + "#Las series más populares\n", + "popularTV = soup.select(\"td.titleColumn a[href^='/title']\")\n", + "popularTV = [name.text for name in popularTV]\n", + "popularTV = list(map(lambda x:x.strip(),popularTV))\n", + "top10 = popularTV[:11]" ] }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ - "brexit = json_normalize(brexit)" + "#Score\n", + "scores = soup.select(\"td.ratingColumn strong\")\n", + "score = [score.text for score in scores]\n", + "top10score = score[:11]" ] }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 80, "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
NameScore
0Watchmen6.8
1Cómo vivir contigo mismo7.4
2Peaky Blinders8.8
3The Walking Dead8.3
4Modern Love8.1
5American Horror Story8.1
6Breaking Bad9.5
7Daybreak6.8
8Batwoman3.2
9Supernatural8.4
10Castle Rock7.7
\n", + "
" + ], "text/plain": [ - "1" + " Name Score\n", + "0 Watchmen 6.8\n", + "1 Cómo vivir contigo mismo 7.4\n", + "2 Peaky Blinders 8.8\n", + "3 The Walking Dead 8.3\n", + "4 Modern Love 8.1\n", + "5 American Horror Story 8.1\n", + "6 Breaking Bad 9.5\n", + "7 Daybreak 6.8\n", + "8 Batwoman 3.2\n", + "9 Supernatural 8.4\n", + "10 Castle Rock 7.7" ] }, - "execution_count": 82, + "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "results = brexit['response.results']\n", + "#Crear el dataframe de las series más populares en IMDB\n", + "columns = [\"Name\", \"Score\"]\n", + "dicttop = {'Name':top10,'Score':top10score}\n", "\n", - "info = [json_normalize(i) for i in results]\n" + "top10df = pd.DataFrame(dicttop, columns=columns)\n", + "top10df" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "#Acceder a API Twitter\n", + "API_KEY = \"CRuEovkPCCTmYVAC8PbndD9N3\"\n", + "API_SECRET = \"SikynKdtF2NpEDpx9xvdtuS9wMHbgQXFAyCq5qj1HYbCJfnhEZ\"\n", + "ACCESS_TOKEN = \"79345899-q0Yb2A2BOfNXkNEjqdFU474r8yARK2WkUqhlTYDjY\"\n", + "ACCESS_TOKEN_SECRET = \"OUD4HI3o11cc4VC2TkTcxSYWTQAcjsh2mlni3SGlkA3fy\"\n", + "\n", + "auth = tweepy.OAuthHandler(API_KEY, API_SECRET)\n", + "auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)\n", + "api = tweepy.API(auth)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [], + "source": [ + "#Buscar los mejores tweets de una serie\n", + "best_tweets = api.search(q='Watchmen', lang = 'en', rpp = 100, result_type='mixed')\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 74, "metadata": {}, "outputs": [ { - "ename": "KeyError", - "evalue": "'webTitle'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2896\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2897\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2898\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'webTitle'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtitlesJson\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbrexit_data\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'webTitle'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mtitles_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mtitle\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mtitle\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtitlesJson\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mtitles_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 2978\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2979\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2980\u001b[0;31m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2981\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2982\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 2897\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2898\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2899\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2900\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2901\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'webTitle'" - ] + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
created_atidid_strtexttruncatedentitiesmetadatasourcein_reply_to_status_idin_reply_to_status_id_str...placecontributorsis_quote_statusretweet_countfavorite_countfavoritedretweetedpossibly_sensitivelangretweeted_status
0Fri Nov 01 17:00:06 +0000 201911903125702442147841190312570244214784Very excited to announce The Official @Watchme...True{'hashtags': [], 'symbols': [], 'user_mentions...{'result_type': 'popular', 'iso_language_code'...<a href=\"https://twittimer.com\" rel=\"nofollow\"...NaNNone...NoneNoneFalse1911450FalseFalseFalseenNaN
1Fri Nov 01 17:00:00 +0000 201911903125455104778251190312545510477825The Official Watchmen Podcast is coming. Join ...True{'hashtags': [{'text': 'Chernobyl', 'indices':...{'result_type': 'popular', 'iso_language_code'...<a href=\"https://studio.twitter.com\" rel=\"nofo...NaNNone...NoneNoneFalse101544FalseFalseFalseenNaN
2Fri Nov 01 15:15:31 +0000 201911902862515109027871190286251510902787white comic fans hate watchmen. but black woma...True{'hashtags': [], 'symbols': [], 'user_mentions...{'result_type': 'popular', 'iso_language_code'...<a href=\"https://mobile.twitter.com\" rel=\"nofo...NaNNone...NoneNoneFalse66400FalseFalseNaNenNaN
3Sat Nov 02 22:59:06 +0000 201911907653050412113921190765305041211392RT @tvs_movies: #TheBatman: William Hoy Film E...False{'hashtags': [{'text': 'TheBatman', 'indices':...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/iphone\" r...NaNNone...NoneNoneFalse470FalseFalseNaNen{'created_at': 'Sat Nov 02 12:50:53 +0000 2019...
4Sat Nov 02 22:58:38 +0000 201911907651875168296961190765187516829696RT @tvs_movies: #TheBatman: William Hoy Film E...False{'hashtags': [{'text': 'TheBatman', 'indices':...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/iphone\" r...NaNNone...NoneNoneFalse470FalseFalseNaNen{'created_at': 'Sat Nov 02 12:50:53 +0000 2019...
5Sat Nov 02 22:58:18 +0000 201911907651039788933121190765103978893312The End Is the Beginning Is the End https://t....True{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"https://mobile.twitter.com\" rel=\"nofo...NaNNone...NoneNoneFalse00FalseFalseFalseenNaN
6Sat Nov 02 22:57:38 +0000 201911907649358290206731190764935829020673Watchmen has a pretty amazing use of colorFalse{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/iphone\" r...NaNNone...NoneNoneFalse00FalseFalseNaNenNaN
7Sat Nov 02 22:57:24 +0000 201911907648753137664001190764875313766400RT @tvs_movies: #TheBatman: William Hoy Film E...False{'hashtags': [{'text': 'TheBatman', 'indices':...{'iso_language_code': 'en', 'result_type': 're...<a href=\"https://mobile.twitter.com\" rel=\"nofo...NaNNone...NoneNoneFalse470FalseFalseNaNen{'created_at': 'Sat Nov 02 12:50:53 +0000 2019...
8Sat Nov 02 22:56:49 +0000 201911907647274351902721190764727435190272@ReginaKing @watchmen @HBO Did it last night. ...True{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/android\" ...1.190723e+181190722756511334400...NoneNoneFalse00FalseFalseFalseenNaN
9Sat Nov 02 22:56:38 +0000 201911907646842968268811190764684296826881RT @tomorrowmanx: @rodimusprime @propjoe757 @K...False{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/android\" ...NaNNone...NoneNoneFalse20FalseFalseNaNen{'created_at': 'Sat Nov 02 21:51:32 +0000 2019...
10Sat Nov 02 22:56:32 +0000 201911907646602130718721190764660213071872@watchmen @ReginaKing @HBO Haha blockedFalse{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"https://mobile.twitter.com\" rel=\"nofo...1.187078e+181187078095146106880...NoneNoneFalse00FalseFalseNaNenNaN
11Sat Nov 02 22:56:22 +0000 201911907646145832796161190764614583279616RT @verge: What DC Comics needs to learn from ...False{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/iphone\" r...NaNNone...NoneNoneFalse130FalseFalseNaNen{'created_at': 'Sat Nov 02 22:01:01 +0000 2019...
12Sat Nov 02 22:56:12 +0000 201911907645759034286081190764575903428608RT @watchmen: \"Breathtaking, first class enter...False{'hashtags': [{'text': 'WatchmenHBO', 'indices...{'iso_language_code': 'en', 'result_type': 're...<a href=\"http://twitter.com/download/android\" ...NaNNone...NoneNoneFalse1570FalseFalseNaNen{'created_at': 'Wed Oct 23 18:47:27 +0000 2019...
13Sat Nov 02 22:55:39 +0000 201911907644346602168331190764434660216833@megankatenelson @watchmen Yes! Just watched e...False{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"https://mobile.twitter.com\" rel=\"nofo...1.190762e+181190761992224739329...NoneNoneFalse01FalseFalseNaNenNaN
14Sat Nov 02 22:54:52 +0000 201911907642402500567041190764240250056704RT @sebingjay: Watchmen is excellent - i’m enj...False{'hashtags': [], 'symbols': [], 'user_mentions...{'iso_language_code': 'en', 'result_type': 're...<a href=\"https://twitter.com/EdinburghWatch\" r...NaNNone...NoneNoneFalse10FalseFalseNaNen{'created_at': 'Sat Nov 02 22:53:36 +0000 2019...
\n", + "

15 rows × 26 columns

\n", + "
" + ], + "text/plain": [ + " created_at id id_str \\\n", + "0 Fri Nov 01 17:00:06 +0000 2019 1190312570244214784 1190312570244214784 \n", + "1 Fri Nov 01 17:00:00 +0000 2019 1190312545510477825 1190312545510477825 \n", + "2 Fri Nov 01 15:15:31 +0000 2019 1190286251510902787 1190286251510902787 \n", + "3 Sat Nov 02 22:59:06 +0000 2019 1190765305041211392 1190765305041211392 \n", + "4 Sat Nov 02 22:58:38 +0000 2019 1190765187516829696 1190765187516829696 \n", + "5 Sat Nov 02 22:58:18 +0000 2019 1190765103978893312 1190765103978893312 \n", + "6 Sat Nov 02 22:57:38 +0000 2019 1190764935829020673 1190764935829020673 \n", + "7 Sat Nov 02 22:57:24 +0000 2019 1190764875313766400 1190764875313766400 \n", + "8 Sat Nov 02 22:56:49 +0000 2019 1190764727435190272 1190764727435190272 \n", + "9 Sat Nov 02 22:56:38 +0000 2019 1190764684296826881 1190764684296826881 \n", + "10 Sat Nov 02 22:56:32 +0000 2019 1190764660213071872 1190764660213071872 \n", + "11 Sat Nov 02 22:56:22 +0000 2019 1190764614583279616 1190764614583279616 \n", + "12 Sat Nov 02 22:56:12 +0000 2019 1190764575903428608 1190764575903428608 \n", + "13 Sat Nov 02 22:55:39 +0000 2019 1190764434660216833 1190764434660216833 \n", + "14 Sat Nov 02 22:54:52 +0000 2019 1190764240250056704 1190764240250056704 \n", + "\n", + " text truncated \\\n", + "0 Very excited to announce The Official @Watchme... True \n", + "1 The Official Watchmen Podcast is coming. Join ... True \n", + "2 white comic fans hate watchmen. but black woma... True \n", + "3 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", + "4 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", + "5 The End Is the Beginning Is the End https://t.... True \n", + "6 Watchmen has a pretty amazing use of color False \n", + "7 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", + "8 @ReginaKing @watchmen @HBO Did it last night. ... True \n", + "9 RT @tomorrowmanx: @rodimusprime @propjoe757 @K... False \n", + "10 @watchmen @ReginaKing @HBO Haha blocked False \n", + "11 RT @verge: What DC Comics needs to learn from ... False \n", + "12 RT @watchmen: \"Breathtaking, first class enter... False \n", + "13 @megankatenelson @watchmen Yes! Just watched e... False \n", + "14 RT @sebingjay: Watchmen is excellent - i’m enj... False \n", + "\n", + " entities \\\n", + "0 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "1 {'hashtags': [{'text': 'Chernobyl', 'indices':... \n", + "2 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "3 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", + "4 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", + "5 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "6 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "7 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", + "8 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "9 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "10 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "11 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "12 {'hashtags': [{'text': 'WatchmenHBO', 'indices... \n", + "13 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "14 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "\n", + " metadata \\\n", + "0 {'result_type': 'popular', 'iso_language_code'... \n", + "1 {'result_type': 'popular', 'iso_language_code'... \n", + "2 {'result_type': 'popular', 'iso_language_code'... \n", + "3 {'iso_language_code': 'en', 'result_type': 're... \n", + "4 {'iso_language_code': 'en', 'result_type': 're... \n", + "5 {'iso_language_code': 'en', 'result_type': 're... \n", + "6 {'iso_language_code': 'en', 'result_type': 're... \n", + "7 {'iso_language_code': 'en', 'result_type': 're... \n", + "8 {'iso_language_code': 'en', 'result_type': 're... \n", + "9 {'iso_language_code': 'en', 'result_type': 're... \n", + "10 {'iso_language_code': 'en', 'result_type': 're... \n", + "11 {'iso_language_code': 'en', 'result_type': 're... \n", + "12 {'iso_language_code': 'en', 'result_type': 're... \n", + "13 {'iso_language_code': 'en', 'result_type': 're... \n", + "14 {'iso_language_code': 'en', 'result_type': 're... \n", + "\n", + " source in_reply_to_status_id \\\n", + "0 \u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbrexit\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'webTitle'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m: 'webTitle'" - ] + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
text
0Very excited to announce The Official @Watchme...
1The Official Watchmen Podcast is coming. Join ...
2white comic fans hate watchmen. but black woma...
3RT @verge: What DC Comics needs to learn from ...
4RT @SnyderContent: Zack Snyder's #Watchmen: Th...
5I have almost zero clue what is happening on W...
6@firststartrmh I think I shall watch Xmas Rob ...
7@megankatenelson @watchmen I am! I have a lot...
8A must watch for anyone watching #Watchmen \\na...
9@ReginaKing @HBO I love this show more than my...
10RT @BSpodNetwork: Want to listen to an intelli...
11Want to listen to an intelligent discussion? C...
12I’m about to rewatch the Watchmen movie.....ne...
13Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5
14@ABatsoulis @MoviesMatrix Yeah im not snyder f...
\n", + "
" + ], + "text/plain": [ + " text\n", + "0 Very excited to announce The Official @Watchme...\n", + "1 The Official Watchmen Podcast is coming. Join ...\n", + "2 white comic fans hate watchmen. but black woma...\n", + "3 RT @verge: What DC Comics needs to learn from ...\n", + "4 RT @SnyderContent: Zack Snyder's #Watchmen: Th...\n", + "5 I have almost zero clue what is happening on W...\n", + "6 @firststartrmh I think I shall watch Xmas Rob ...\n", + "7 @megankatenelson @watchmen I am! I have a lot...\n", + "8 A must watch for anyone watching #Watchmen \\na...\n", + "9 @ReginaKing @HBO I love this show more than my...\n", + "10 RT @BSpodNetwork: Want to listen to an intelli...\n", + "11 Want to listen to an intelligent discussion? C...\n", + "12 I’m about to rewatch the Watchmen movie.....ne...\n", + "13 Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5\n", + "14 @ABatsoulis @MoviesMatrix Yeah im not snyder f..." + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Convertirlo a dataframe\n", + "tweetsdf= pd.DataFrame(text)\n", + "tweetsdf" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": {}, + "outputs": [], + "source": [ + "#función para clasificar tweets\n", + "def get_tweet_sentiment(tweet): \n", + " ''' \n", + " Utility function to classify sentiment of passed tweet \n", + " using textblob's sentiment method \n", + " '''\n", + " # create TextBlob object of passed tweet text \n", + " analysis = TextBlob(tweet) \n", + " # set sentiment \n", + " if analysis.sentiment.polarity > 0: \n", + " return 'positive'\n", + " elif analysis.sentiment.polarity == 0: \n", + " return 'neutral'\n", + " else: \n", + " return 'negative'" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [], + "source": [ + "#Aplicar tweets a todo\n", + "sentiments = tweetsdf['text'].apply(get_tweet_sentiment)" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
textSentiments
0Very excited to announce The Official @Watchme...positive
1The Official Watchmen Podcast is coming. Join ...neutral
2white comic fans hate watchmen. but black woma...negative
3RT @verge: What DC Comics needs to learn from ...negative
4RT @SnyderContent: Zack Snyder's #Watchmen: Th...neutral
5I have almost zero clue what is happening on W...positive
6@firststartrmh I think I shall watch Xmas Rob ...positive
7@megankatenelson @watchmen I am! I have a lot...neutral
8A must watch for anyone watching #Watchmen \\na...positive
9@ReginaKing @HBO I love this show more than my...positive
10RT @BSpodNetwork: Want to listen to an intelli...positive
11Want to listen to an intelligent discussion? C...positive
12I’m about to rewatch the Watchmen movie.....ne...neutral
13Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5neutral
14@ABatsoulis @MoviesMatrix Yeah im not snyder f...neutral
\n", + "
" + ], + "text/plain": [ + " text Sentiments\n", + "0 Very excited to announce The Official @Watchme... positive\n", + "1 The Official Watchmen Podcast is coming. Join ... neutral\n", + "2 white comic fans hate watchmen. but black woma... negative\n", + "3 RT @verge: What DC Comics needs to learn from ... negative\n", + "4 RT @SnyderContent: Zack Snyder's #Watchmen: Th... neutral\n", + "5 I have almost zero clue what is happening on W... positive\n", + "6 @firststartrmh I think I shall watch Xmas Rob ... positive\n", + "7 @megankatenelson @watchmen I am! I have a lot... neutral\n", + "8 A must watch for anyone watching #Watchmen \\na... positive\n", + "9 @ReginaKing @HBO I love this show more than my... positive\n", + "10 RT @BSpodNetwork: Want to listen to an intelli... positive\n", + "11 Want to listen to an intelligent discussion? C... positive\n", + "12 I’m about to rewatch the Watchmen movie.....ne... neutral\n", + "13 Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5 neutral\n", + "14 @ABatsoulis @MoviesMatrix Yeah im not snyder f... neutral" + ] + }, + "execution_count": 99, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "brexit['webTitle']" + "tweetsdf['Sentiments'] = sentiments\n", + "tweetsdf" ] }, { diff --git a/your-code/Scraping.ipynb b/your-code/Scraping.ipynb index 7b53a00..b697059 100644 --- a/your-code/Scraping.ipynb +++ b/your-code/Scraping.ipynb @@ -159,15 +159,139 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "['7', '6', '5', '4', '3', '2', '1']" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "seasons = soup.select(\"div.seasons-and-year-nav a[href^='/title']\")\n", - "\n", - "characters = [name.text for name in characters]\n", - "\n" + "seasons = soup.select(\"div.seasons-and-year-nav a[href*='season']\")\n", + "seasons = [season.text for season in seasons]\n", + "seasons\n" ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['2015', '2014', '2013', '2012', '2010', '2009']" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "years = soup.select(\"div.seasons-and-year-nav a[href*='year']\")\n", + "years = [year.text for year in years]\n", + "years" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[], [], [], [], [], [], [], [], [], [], [], []]" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ratingValue" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " None,\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " [],\n", + " []]" + ] + }, + "execution_count": 87, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/your-code/Scraping2.ipynb b/your-code/Scraping2.ipynb new file mode 100644 index 0000000..70e117d --- /dev/null +++ b/your-code/Scraping2.ipynb @@ -0,0 +1,166 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "url = 'https://www.imdb.com/chart/tvmeter?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=4da9d9a5-d299-43f2-9c53-f0efa18182cd&pf_rd_r=0KYJP3BJH5DN6EZWRQ5Z&pf_rd_s=right-4&pf_rd_t=15506&pf_rd_i=toptv&ref_=chttvtp_ql_5'" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "soup = requests.get(url).content\n", + "soup = BeautifulSoup(soup,'html.parser')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "#Las series más populares\n", + "popularTV = soup.select(\"td.titleColumn a[href^='/title']\")\n", + "popularTV = [name.text for name in popularTV]\n", + "popularTV = list(map(lambda x:x.strip(),popularTV))\n", + "top20 = popularTV[:11]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "#Score\n", + "scores = soup.select(\"td.ratingColumn strong\")\n", + "score = [score.text for score in scores]\n", + "top20score = score[:11]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Watchmen',\n", + " 'Cómo vivir contigo mismo',\n", + " 'Peaky Blinders',\n", + " 'The Walking Dead',\n", + " 'Modern Love',\n", + " 'American Horror Story',\n", + " 'Breaking Bad',\n", + " 'Daybreak',\n", + " 'Batwoman',\n", + " 'Supernatural',\n", + " 'Castle Rock']" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "top20\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['6.8', '7.4', '8.8', '8.3', '8.1', '8.1', '9.5', '6.8', '3.2', '8.4', '7.7']" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "top20score\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b72841d26f8963e8051b735c84553024408afe6a Mon Sep 17 00:00:00 2001 From: Nancy Sanchez Date: Sat, 2 Nov 2019 17:28:39 -0600 Subject: [PATCH 3/4] =?UTF-8?q?Avance=20m=C3=A1s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 6148 -> 6148 bytes your-code/API.ipynb | 680 +++++++++++++++++++------------------------- 2 files changed, 296 insertions(+), 384 deletions(-) diff --git a/.DS_Store b/.DS_Store index 1bcb28b850209a11ffa97ffe59f045f24155c26d..cc99851c5876e9ee3666feb9cdba403332ea7e22 100644 GIT binary patch delta 132 zcmZoMXffEJ#$>ThoPmLXg+Y%YogtHNOF_om}D3q zOn%EGE|8OM7@VA+TL4zh*d8*? IIsWnk08MZzivR!s delta 132 zcmZoMXffEJ#$?f4!oa}5!l1{H&XCDalAG`1l2Tfd%)oH-ano|342oO|lHBAtCK<+r z$#0p&1#;32gOl@f3&6@5d;d*-$0Rm+2NMs|ftQotFiA|l2V<%+9@wnN{ETH{0pDhJ Hj=%f>6%8tX diff --git a/your-code/API.ipynb b/your-code/API.ipynb index 09368b4..6230149 100644 --- a/your-code/API.ipynb +++ b/your-code/API.ipynb @@ -204,18 +204,18 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 101, "metadata": {}, "outputs": [], "source": [ "#Buscar los mejores tweets de una serie\n", - "best_tweets = api.search(q='Watchmen', lang = 'en', rpp = 100, result_type='mixed')\n", + "best_tweets = api.search(q='Watchmen', lang = 'en', count = 100, result_type='mixed')\n", "\n" ] }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 102, "metadata": {}, "outputs": [ { @@ -250,16 +250,16 @@ " in_reply_to_status_id\n", " in_reply_to_status_id_str\n", " ...\n", - " place\n", - " contributors\n", - " is_quote_status\n", - " retweet_count\n", " favorite_count\n", " favorited\n", " retweeted\n", " possibly_sensitive\n", " lang\n", " retweeted_status\n", + " quoted_status_id\n", + " quoted_status_id_str\n", + " quoted_status\n", + " extended_entities\n", " \n", " \n", " \n", @@ -276,16 +276,16 @@ " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 191\n", - " 1450\n", + " 1452\n", " False\n", " False\n", " False\n", " en\n", " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", " 1\n", @@ -300,16 +300,16 @@ " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 101\n", " 544\n", " False\n", " False\n", " False\n", " en\n", " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", " 2\n", @@ -324,215 +324,191 @@ " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 66\n", - " 400\n", + " 401\n", " False\n", " False\n", " NaN\n", " en\n", " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", " 3\n", - " Sat Nov 02 22:59:06 +0000 2019\n", - " 1190765305041211392\n", - " 1190765305041211392\n", - " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", + " Sat Nov 02 23:27:42 +0000 2019\n", + " 1190772503104413696\n", + " 1190772503104413696\n", + " @ProperOpinion Thought the same about the watc...\n", " False\n", - " {'hashtags': [{'text': 'TheBatman', 'indices':...\n", + " {'hashtags': [], 'symbols': [], 'user_mentions...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", " <a href=\"http://twitter.com/download/iphone\" r...\n", - " NaN\n", - " None\n", + " 1.190757e+18\n", + " 1190757443216785409\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 47\n", - " 0\n", + " 1\n", " False\n", " False\n", " NaN\n", " en\n", - " {'created_at': 'Sat Nov 02 12:50:53 +0000 2019...\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", " 4\n", - " Sat Nov 02 22:58:38 +0000 2019\n", - " 1190765187516829696\n", - " 1190765187516829696\n", - " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", + " Sat Nov 02 23:27:42 +0000 2019\n", + " 1190772500075929600\n", + " 1190772500075929600\n", + " @ReginaKing @HBO You’re awesome in The Leftove...\n", " False\n", - " {'hashtags': [{'text': 'TheBatman', 'indices':...\n", + " {'hashtags': [], 'symbols': [], 'user_mentions...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", " <a href=\"http://twitter.com/download/iphone\" r...\n", - " NaN\n", - " None\n", + " 1.190723e+18\n", + " 1190722756511334400\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 47\n", " 0\n", " False\n", " False\n", " NaN\n", " en\n", - " {'created_at': 'Sat Nov 02 12:50:53 +0000 2019...\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", - " 5\n", - " Sat Nov 02 22:58:18 +0000 2019\n", - " 1190765103978893312\n", - " 1190765103978893312\n", - " The End Is the Beginning Is the End https://t....\n", - " True\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " ...\n", + " \n", + " \n", + " 95\n", + " Sat Nov 02 22:59:19 +0000 2019\n", + " 1190765360116621320\n", + " 1190765360116621320\n", + " RT @michaelharriot: Thread:\\n\\nA lot of white ...\n", + " False\n", " {'hashtags': [], 'symbols': [], 'user_mentions...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"https://mobile.twitter.com\" rel=\"nofo...\n", + " <a href=\"http://twitter.com/download/android\" ...\n", " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", " 0\n", - " 0\n", - " False\n", " False\n", " False\n", + " NaN\n", " en\n", + " {'created_at': 'Tue Oct 22 02:24:21 +0000 2019...\n", + " NaN\n", + " NaN\n", + " NaN\n", " NaN\n", " \n", " \n", - " 6\n", - " Sat Nov 02 22:57:38 +0000 2019\n", - " 1190764935829020673\n", - " 1190764935829020673\n", - " Watchmen has a pretty amazing use of color\n", + " 96\n", + " Sat Nov 02 22:59:06 +0000 2019\n", + " 1190765305041211392\n", + " 1190765305041211392\n", + " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", " False\n", - " {'hashtags': [], 'symbols': [], 'user_mentions...\n", + " {'hashtags': [{'text': 'TheBatman', 'indices':...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", " <a href=\"http://twitter.com/download/iphone\" r...\n", " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 0\n", " 0\n", " False\n", " False\n", " NaN\n", " en\n", + " {'created_at': 'Sat Nov 02 12:50:53 +0000 2019...\n", + " NaN\n", + " NaN\n", + " NaN\n", " NaN\n", " \n", " \n", - " 7\n", - " Sat Nov 02 22:57:24 +0000 2019\n", - " 1190764875313766400\n", - " 1190764875313766400\n", + " 97\n", + " Sat Nov 02 22:58:38 +0000 2019\n", + " 1190765187516829696\n", + " 1190765187516829696\n", " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", " False\n", " {'hashtags': [{'text': 'TheBatman', 'indices':...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"https://mobile.twitter.com\" rel=\"nofo...\n", + " <a href=\"http://twitter.com/download/iphone\" r...\n", " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 47\n", " 0\n", " False\n", " False\n", " NaN\n", " en\n", " {'created_at': 'Sat Nov 02 12:50:53 +0000 2019...\n", + " NaN\n", + " NaN\n", + " NaN\n", + " NaN\n", " \n", " \n", - " 8\n", - " Sat Nov 02 22:56:49 +0000 2019\n", - " 1190764727435190272\n", - " 1190764727435190272\n", - " @ReginaKing @watchmen @HBO Did it last night. ...\n", + " 98\n", + " Sat Nov 02 22:58:18 +0000 2019\n", + " 1190765103978893312\n", + " 1190765103978893312\n", + " The End Is the Beginning Is the End https://t....\n", " True\n", " {'hashtags': [], 'symbols': [], 'user_mentions...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"http://twitter.com/download/android\" ...\n", - " 1.190723e+18\n", - " 1190722756511334400\n", - " ...\n", - " None\n", + " <a href=\"https://mobile.twitter.com\" rel=\"nofo...\n", + " NaN\n", " None\n", - " False\n", - " 0\n", + " ...\n", " 0\n", " False\n", " False\n", " False\n", " en\n", " NaN\n", - " \n", - " \n", - " 9\n", - " Sat Nov 02 22:56:38 +0000 2019\n", - " 1190764684296826881\n", - " 1190764684296826881\n", - " RT @tomorrowmanx: @rodimusprime @propjoe757 @K...\n", - " False\n", - " {'hashtags': [], 'symbols': [], 'user_mentions...\n", - " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"http://twitter.com/download/android\" ...\n", " NaN\n", - " None\n", - " ...\n", - " None\n", - " None\n", - " False\n", - " 2\n", - " 0\n", - " False\n", - " False\n", " NaN\n", - " en\n", - " {'created_at': 'Sat Nov 02 21:51:32 +0000 2019...\n", - " \n", - " \n", - " 10\n", - " Sat Nov 02 22:56:32 +0000 2019\n", - " 1190764660213071872\n", - " 1190764660213071872\n", - " @watchmen @ReginaKing @HBO Haha blocked\n", - " False\n", - " {'hashtags': [], 'symbols': [], 'user_mentions...\n", - " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"https://mobile.twitter.com\" rel=\"nofo...\n", - " 1.187078e+18\n", - " 1187078095146106880\n", - " ...\n", - " None\n", - " None\n", - " False\n", - " 0\n", - " 0\n", - " False\n", - " False\n", " NaN\n", - " en\n", " NaN\n", " \n", " \n", - " 11\n", - " Sat Nov 02 22:56:22 +0000 2019\n", - " 1190764614583279616\n", - " 1190764614583279616\n", - " RT @verge: What DC Comics needs to learn from ...\n", + " 99\n", + " Sat Nov 02 22:57:38 +0000 2019\n", + " 1190764935829020673\n", + " 1190764935829020673\n", + " Watchmen has a pretty amazing use of color\n", " False\n", " {'hashtags': [], 'symbols': [], 'user_mentions...\n", " {'iso_language_code': 'en', 'result_type': 're...\n", @@ -540,92 +516,20 @@ " NaN\n", " None\n", " ...\n", - " None\n", - " None\n", - " False\n", - " 13\n", " 0\n", " False\n", " False\n", " NaN\n", " en\n", - " {'created_at': 'Sat Nov 02 22:01:01 +0000 2019...\n", - " \n", - " \n", - " 12\n", - " Sat Nov 02 22:56:12 +0000 2019\n", - " 1190764575903428608\n", - " 1190764575903428608\n", - " RT @watchmen: \"Breathtaking, first class enter...\n", - " False\n", - " {'hashtags': [{'text': 'WatchmenHBO', 'indices...\n", - " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"http://twitter.com/download/android\" ...\n", " NaN\n", - " None\n", - " ...\n", - " None\n", - " None\n", - " False\n", - " 157\n", - " 0\n", - " False\n", - " False\n", " NaN\n", - " en\n", - " {'created_at': 'Wed Oct 23 18:47:27 +0000 2019...\n", - " \n", - " \n", - " 13\n", - " Sat Nov 02 22:55:39 +0000 2019\n", - " 1190764434660216833\n", - " 1190764434660216833\n", - " @megankatenelson @watchmen Yes! Just watched e...\n", - " False\n", - " {'hashtags': [], 'symbols': [], 'user_mentions...\n", - " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"https://mobile.twitter.com\" rel=\"nofo...\n", - " 1.190762e+18\n", - " 1190761992224739329\n", - " ...\n", - " None\n", - " None\n", - " False\n", - " 0\n", - " 1\n", - " False\n", - " False\n", " NaN\n", - " en\n", - " NaN\n", - " \n", - " \n", - " 14\n", - " Sat Nov 02 22:54:52 +0000 2019\n", - " 1190764240250056704\n", - " 1190764240250056704\n", - " RT @sebingjay: Watchmen is excellent - i’m enj...\n", - " False\n", - " {'hashtags': [], 'symbols': [], 'user_mentions...\n", - " {'iso_language_code': 'en', 'result_type': 're...\n", - " <a href=\"https://twitter.com/EdinburghWatch\" r...\n", " NaN\n", - " None\n", - " ...\n", - " None\n", - " None\n", - " False\n", - " 1\n", - " 0\n", - " False\n", - " False\n", " NaN\n", - " en\n", - " {'created_at': 'Sat Nov 02 22:53:36 +0000 2019...\n", " \n", " \n", "\n", - "

15 rows × 26 columns

\n", + "

100 rows × 30 columns

\n", "" ], "text/plain": [ @@ -633,52 +537,40 @@ "0 Fri Nov 01 17:00:06 +0000 2019 1190312570244214784 1190312570244214784 \n", "1 Fri Nov 01 17:00:00 +0000 2019 1190312545510477825 1190312545510477825 \n", "2 Fri Nov 01 15:15:31 +0000 2019 1190286251510902787 1190286251510902787 \n", - "3 Sat Nov 02 22:59:06 +0000 2019 1190765305041211392 1190765305041211392 \n", - "4 Sat Nov 02 22:58:38 +0000 2019 1190765187516829696 1190765187516829696 \n", - "5 Sat Nov 02 22:58:18 +0000 2019 1190765103978893312 1190765103978893312 \n", - "6 Sat Nov 02 22:57:38 +0000 2019 1190764935829020673 1190764935829020673 \n", - "7 Sat Nov 02 22:57:24 +0000 2019 1190764875313766400 1190764875313766400 \n", - "8 Sat Nov 02 22:56:49 +0000 2019 1190764727435190272 1190764727435190272 \n", - "9 Sat Nov 02 22:56:38 +0000 2019 1190764684296826881 1190764684296826881 \n", - "10 Sat Nov 02 22:56:32 +0000 2019 1190764660213071872 1190764660213071872 \n", - "11 Sat Nov 02 22:56:22 +0000 2019 1190764614583279616 1190764614583279616 \n", - "12 Sat Nov 02 22:56:12 +0000 2019 1190764575903428608 1190764575903428608 \n", - "13 Sat Nov 02 22:55:39 +0000 2019 1190764434660216833 1190764434660216833 \n", - "14 Sat Nov 02 22:54:52 +0000 2019 1190764240250056704 1190764240250056704 \n", + "3 Sat Nov 02 23:27:42 +0000 2019 1190772503104413696 1190772503104413696 \n", + "4 Sat Nov 02 23:27:42 +0000 2019 1190772500075929600 1190772500075929600 \n", + ".. ... ... ... \n", + "95 Sat Nov 02 22:59:19 +0000 2019 1190765360116621320 1190765360116621320 \n", + "96 Sat Nov 02 22:59:06 +0000 2019 1190765305041211392 1190765305041211392 \n", + "97 Sat Nov 02 22:58:38 +0000 2019 1190765187516829696 1190765187516829696 \n", + "98 Sat Nov 02 22:58:18 +0000 2019 1190765103978893312 1190765103978893312 \n", + "99 Sat Nov 02 22:57:38 +0000 2019 1190764935829020673 1190764935829020673 \n", "\n", " text truncated \\\n", "0 Very excited to announce The Official @Watchme... True \n", "1 The Official Watchmen Podcast is coming. Join ... True \n", "2 white comic fans hate watchmen. but black woma... True \n", - "3 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", - "4 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", - "5 The End Is the Beginning Is the End https://t.... True \n", - "6 Watchmen has a pretty amazing use of color False \n", - "7 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", - "8 @ReginaKing @watchmen @HBO Did it last night. ... True \n", - "9 RT @tomorrowmanx: @rodimusprime @propjoe757 @K... False \n", - "10 @watchmen @ReginaKing @HBO Haha blocked False \n", - "11 RT @verge: What DC Comics needs to learn from ... False \n", - "12 RT @watchmen: \"Breathtaking, first class enter... False \n", - "13 @megankatenelson @watchmen Yes! Just watched e... False \n", - "14 RT @sebingjay: Watchmen is excellent - i’m enj... False \n", + "3 @ProperOpinion Thought the same about the watc... False \n", + "4 @ReginaKing @HBO You’re awesome in The Leftove... False \n", + ".. ... ... \n", + "95 RT @michaelharriot: Thread:\\n\\nA lot of white ... False \n", + "96 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", + "97 RT @tvs_movies: #TheBatman: William Hoy Film E... False \n", + "98 The End Is the Beginning Is the End https://t.... True \n", + "99 Watchmen has a pretty amazing use of color False \n", "\n", " entities \\\n", "0 {'hashtags': [], 'symbols': [], 'user_mentions... \n", "1 {'hashtags': [{'text': 'Chernobyl', 'indices':... \n", "2 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "3 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", - "4 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", - "5 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "6 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "7 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", - "8 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "9 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "10 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "11 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "12 {'hashtags': [{'text': 'WatchmenHBO', 'indices... \n", - "13 {'hashtags': [], 'symbols': [], 'user_mentions... \n", - "14 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "3 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "4 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + ".. ... \n", + "95 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "96 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", + "97 {'hashtags': [{'text': 'TheBatman', 'indices':... \n", + "98 {'hashtags': [], 'symbols': [], 'user_mentions... \n", + "99 {'hashtags': [], 'symbols': [], 'user_mentions... \n", "\n", " metadata \\\n", "0 {'result_type': 'popular', 'iso_language_code'... \n", @@ -686,89 +578,69 @@ "2 {'result_type': 'popular', 'iso_language_code'... \n", "3 {'iso_language_code': 'en', 'result_type': 're... \n", "4 {'iso_language_code': 'en', 'result_type': 're... \n", - "5 {'iso_language_code': 'en', 'result_type': 're... \n", - "6 {'iso_language_code': 'en', 'result_type': 're... \n", - "7 {'iso_language_code': 'en', 'result_type': 're... \n", - "8 {'iso_language_code': 'en', 'result_type': 're... \n", - "9 {'iso_language_code': 'en', 'result_type': 're... \n", - "10 {'iso_language_code': 'en', 'result_type': 're... \n", - "11 {'iso_language_code': 'en', 'result_type': 're... \n", - "12 {'iso_language_code': 'en', 'result_type': 're... \n", - "13 {'iso_language_code': 'en', 'result_type': 're... \n", - "14 {'iso_language_code': 'en', 'result_type': 're... \n", + ".. ... \n", + "95 {'iso_language_code': 'en', 'result_type': 're... \n", + "96 {'iso_language_code': 'en', 'result_type': 're... \n", + "97 {'iso_language_code': 'en', 'result_type': 're... \n", + "98 {'iso_language_code': 'en', 'result_type': 're... \n", + "99 {'iso_language_code': 'en', 'result_type': 're... \n", "\n", " source in_reply_to_status_id \\\n", "0
\n", " \n", " 3\n", - " RT @verge: What DC Comics needs to learn from ...\n", + " @ProperOpinion Thought the same about the watc...\n", " \n", " \n", " 4\n", - " RT @SnyderContent: Zack Snyder's #Watchmen: Th...\n", - " \n", - " \n", - " 5\n", - " I have almost zero clue what is happening on W...\n", + " @ReginaKing @HBO You’re awesome in The Leftove...\n", " \n", " \n", - " 6\n", - " @firststartrmh I think I shall watch Xmas Rob ...\n", - " \n", - " \n", - " 7\n", - " @megankatenelson @watchmen I am! I have a lot...\n", - " \n", - " \n", - " 8\n", - " A must watch for anyone watching #Watchmen \\na...\n", - " \n", - " \n", - " 9\n", - " @ReginaKing @HBO I love this show more than my...\n", + " ...\n", + " ...\n", " \n", " \n", - " 10\n", - " RT @BSpodNetwork: Want to listen to an intelli...\n", + " 95\n", + " RT @michaelharriot: Thread:\\n\\nA lot of white ...\n", " \n", " \n", - " 11\n", - " Want to listen to an intelligent discussion? C...\n", + " 96\n", + " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", " \n", " \n", - " 12\n", - " I’m about to rewatch the Watchmen movie.....ne...\n", + " 97\n", + " RT @tvs_movies: #TheBatman: William Hoy Film E...\n", " \n", " \n", - " 13\n", - " Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5\n", + " 98\n", + " The End Is the Beginning Is the End https://t....\n", " \n", " \n", - " 14\n", - " @ABatsoulis @MoviesMatrix Yeah im not snyder f...\n", + " 99\n", + " Watchmen has a pretty amazing use of color\n", " \n", " \n", "\n", + "

100 rows × 1 columns

\n", "" ], "text/plain": [ @@ -892,21 +749,19 @@ "0 Very excited to announce The Official @Watchme...\n", "1 The Official Watchmen Podcast is coming. Join ...\n", "2 white comic fans hate watchmen. but black woma...\n", - "3 RT @verge: What DC Comics needs to learn from ...\n", - "4 RT @SnyderContent: Zack Snyder's #Watchmen: Th...\n", - "5 I have almost zero clue what is happening on W...\n", - "6 @firststartrmh I think I shall watch Xmas Rob ...\n", - "7 @megankatenelson @watchmen I am! I have a lot...\n", - "8 A must watch for anyone watching #Watchmen \\na...\n", - "9 @ReginaKing @HBO I love this show more than my...\n", - "10 RT @BSpodNetwork: Want to listen to an intelli...\n", - "11 Want to listen to an intelligent discussion? C...\n", - "12 I’m about to rewatch the Watchmen movie.....ne...\n", - "13 Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5\n", - "14 @ABatsoulis @MoviesMatrix Yeah im not snyder f..." + "3 @ProperOpinion Thought the same about the watc...\n", + "4 @ReginaKing @HBO You’re awesome in The Leftove...\n", + ".. ...\n", + "95 RT @michaelharriot: Thread:\\n\\nA lot of white ...\n", + "96 RT @tvs_movies: #TheBatman: William Hoy Film E...\n", + "97 RT @tvs_movies: #TheBatman: William Hoy Film E...\n", + "98 The End Is the Beginning Is the End https://t....\n", + "99 Watchmen has a pretty amazing use of color\n", + "\n", + "[100 rows x 1 columns]" ] }, - "execution_count": 67, + "execution_count": 104, "metadata": {}, "output_type": "execute_result" } @@ -952,7 +807,7 @@ }, { "cell_type": "code", - "execution_count": 99, + "execution_count": 100, "metadata": {}, "outputs": [ { @@ -978,6 +833,7 @@ " \n", " text\n", " Sentiments\n", + " sentiments\n", " \n", " \n", " \n", @@ -985,107 +841,122 @@ " 0\n", " Very excited to announce The Official @Watchme...\n", " positive\n", + " positive\n", " \n", " \n", " 1\n", " The Official Watchmen Podcast is coming. Join ...\n", " neutral\n", + " neutral\n", " \n", " \n", " 2\n", " white comic fans hate watchmen. but black woma...\n", " negative\n", + " negative\n", " \n", " \n", " 3\n", " RT @verge: What DC Comics needs to learn from ...\n", " negative\n", + " negative\n", " \n", " \n", " 4\n", " RT @SnyderContent: Zack Snyder's #Watchmen: Th...\n", " neutral\n", + " neutral\n", " \n", " \n", " 5\n", " I have almost zero clue what is happening on W...\n", " positive\n", + " positive\n", " \n", " \n", " 6\n", " @firststartrmh I think I shall watch Xmas Rob ...\n", " positive\n", + " positive\n", " \n", " \n", " 7\n", " @megankatenelson @watchmen I am! I have a lot...\n", " neutral\n", + " neutral\n", " \n", " \n", " 8\n", " A must watch for anyone watching #Watchmen \\na...\n", " positive\n", + " positive\n", " \n", " \n", " 9\n", " @ReginaKing @HBO I love this show more than my...\n", " positive\n", + " positive\n", " \n", " \n", " 10\n", " RT @BSpodNetwork: Want to listen to an intelli...\n", " positive\n", + " positive\n", " \n", " \n", " 11\n", " Want to listen to an intelligent discussion? C...\n", " positive\n", + " positive\n", " \n", " \n", " 12\n", " I’m about to rewatch the Watchmen movie.....ne...\n", " neutral\n", + " neutral\n", " \n", " \n", " 13\n", " Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5\n", " neutral\n", + " neutral\n", " \n", " \n", " 14\n", " @ABatsoulis @MoviesMatrix Yeah im not snyder f...\n", " neutral\n", + " neutral\n", " \n", " \n", "\n", "" ], "text/plain": [ - " text Sentiments\n", - "0 Very excited to announce The Official @Watchme... positive\n", - "1 The Official Watchmen Podcast is coming. Join ... neutral\n", - "2 white comic fans hate watchmen. but black woma... negative\n", - "3 RT @verge: What DC Comics needs to learn from ... negative\n", - "4 RT @SnyderContent: Zack Snyder's #Watchmen: Th... neutral\n", - "5 I have almost zero clue what is happening on W... positive\n", - "6 @firststartrmh I think I shall watch Xmas Rob ... positive\n", - "7 @megankatenelson @watchmen I am! I have a lot... neutral\n", - "8 A must watch for anyone watching #Watchmen \\na... positive\n", - "9 @ReginaKing @HBO I love this show more than my... positive\n", - "10 RT @BSpodNetwork: Want to listen to an intelli... positive\n", - "11 Want to listen to an intelligent discussion? C... positive\n", - "12 I’m about to rewatch the Watchmen movie.....ne... neutral\n", - "13 Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5 neutral\n", - "14 @ABatsoulis @MoviesMatrix Yeah im not snyder f... neutral" + " text Sentiments sentiments\n", + "0 Very excited to announce The Official @Watchme... positive positive\n", + "1 The Official Watchmen Podcast is coming. Join ... neutral neutral\n", + "2 white comic fans hate watchmen. but black woma... negative negative\n", + "3 RT @verge: What DC Comics needs to learn from ... negative negative\n", + "4 RT @SnyderContent: Zack Snyder's #Watchmen: Th... neutral neutral\n", + "5 I have almost zero clue what is happening on W... positive positive\n", + "6 @firststartrmh I think I shall watch Xmas Rob ... positive positive\n", + "7 @megankatenelson @watchmen I am! I have a lot... neutral neutral\n", + "8 A must watch for anyone watching #Watchmen \\na... positive positive\n", + "9 @ReginaKing @HBO I love this show more than my... positive positive\n", + "10 RT @BSpodNetwork: Want to listen to an intelli... positive positive\n", + "11 Want to listen to an intelligent discussion? C... positive positive\n", + "12 I’m about to rewatch the Watchmen movie.....ne... neutral neutral\n", + "13 Yes sis!! @sadiquabynum https://t.co/6bRKYVFGa5 neutral neutral\n", + "14 @ABatsoulis @MoviesMatrix Yeah im not snyder f... neutral neutral" ] }, - "execution_count": 99, + "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "tweetsdf['Sentiments'] = sentiments\n", + "tweetsdf['sentiments'] = sentiments\n", "tweetsdf" ] }, @@ -1094,7 +965,48 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def main(): \n", + " # creating object of TwitterClient Class \n", + " api = TwitterClient() \n", + " # calling function to get tweets \n", + " tweets = api.get_tweets(query = 'Donald Trump', count = 200) \n", + " \n", + " # picking positive tweets from tweets \n", + " ptweets = [tweet for tweet in tweets if tweet['sentiment'] == 'positive'] \n", + " # percentage of positive tweets \n", + " print(\"Positive tweets percentage: {} %\".format(100*len(ptweets)/len(tweets))) \n", + " # picking negative tweets from tweets \n", + " ntweets = [tweet for tweet in tweets if tweet['sentiment'] == 'negative'] \n", + " # percentage of negative tweets \n", + " print(\"Negative tweets percentage: {} %\".format(100*len(ntweets)/len(tweets))) \n", + " # percentage of neutral tweets \n", + " print(\"Neutral tweets percentage: {} % \\ \n", + " \".format(100*len(tweets - ntweets - ptweets)/len(tweets))) \n", + " \n", + " # printing first 5 positive tweets \n", + " print(\"\\n\\nPositive tweets:\") \n", + " for tweet in ptweets[:10]: \n", + " print(tweet['text']) \n", + " \n", + " # printing first 5 negative tweets \n", + " print(\"\\n\\nNegative tweets:\") \n", + " for tweet in ntweets[:10]: \n", + " print(tweet['text']) \n", + " \n", + "if __name__ == \"__main__\": \n", + " # calling main function \n", + " main() " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tweets = api.get_tweets(query = 'Donald Trump', count = 200)" + ] } ], "metadata": { From c567e22af4a8caa1d73ddfd13c1d18df65c88d9c Mon Sep 17 00:00:00 2001 From: Nancy Sanchez Date: Sun, 3 Nov 2019 16:14:57 -0600 Subject: [PATCH 4/4] =?UTF-8?q?Muchas=20l=C3=A1grimas=20desp=C3=BAes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- your-code/Lab- proyecto API&Web.ipynb | 1167 +++++++++++++++++++++++++ 1 file changed, 1167 insertions(+) create mode 100644 your-code/Lab- proyecto API&Web.ipynb diff --git a/your-code/Lab- proyecto API&Web.ipynb b/your-code/Lab- proyecto API&Web.ipynb new file mode 100644 index 0000000..1a6a6e6 --- /dev/null +++ b/your-code/Lab- proyecto API&Web.ipynb @@ -0,0 +1,1167 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "import requests\n", + "import pandas as pd\n", + "from pandas.io.json import json_normalize\n", + "import tweepy\n", + "import re \n", + "from tweepy import OAuthHandler \n", + "from textblob import TextBlob\n", + "import requests\n", + "from bs4 import BeautifulSoup\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "def get_top_five():\n", + " #Parsing del link\n", + " url = 'https://www.imdb.com/chart/tvmeter?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=4da9d9a5-d299-43f2-9c53-f0efa18182cd&pf_rd_r=0KYJP3BJH5DN6EZWRQ5Z&pf_rd_s=right-4&pf_rd_t=15506&pf_rd_i=toptv&ref_=chttvtp_ql_5'\n", + " soup = requests.get(url).content\n", + " soup = BeautifulSoup(soup,'html.parser')\n", + " \n", + " #Conseguir los títulos de las series más populares\n", + " popularTV = soup.select(\"td.titleColumn a[href^='/title']\")\n", + " popularTV = [name.text for name in popularTV]\n", + " popularTV = list(map(lambda x:x.strip(),popularTV))\n", + " top5 = popularTV[:6]\n", + " \n", + " #Conseguir el score de las series más populares\n", + " scores = soup.select(\"td.ratingColumn strong\")\n", + " score = [score.text for score in scores]\n", + " top5score = score[:6]\n", + " \n", + " #Crear el dataframe de las series más populares en IMDB\n", + " columns = [\"Name\", \"Score\"]\n", + " dicttop = {'Name':top5,'Score':top5score}\n", + "\n", + " global top5df\n", + " \n", + " top5df = pd.DataFrame(dicttop, columns=columns)\n", + " return top5df" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
NameScore
0Watchmen6.8
1Cómo vivir contigo mismo7.4
2Peaky Blinders8.8
3The Walking Dead8.3
4Modern Love8.1
5American Horror Story8.1
\n", + "
" + ], + "text/plain": [ + " Name Score\n", + "0 Watchmen 6.8\n", + "1 Cómo vivir contigo mismo 7.4\n", + "2 Peaky Blinders 8.8\n", + "3 The Walking Dead 8.3\n", + "4 Modern Love 8.1\n", + "5 American Horror Story 8.1" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "get_top_five()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "def access_Twitter_API(): \n", + " # Mis credenciales \n", + " API_KEY = \"CRuEovkPCCTmYVAC8PbndD9N3\"\n", + " API_SECRET = \"SikynKdtF2NpEDpx9xvdtuS9wMHbgQXFAyCq5qj1HYbCJfnhEZ\"\n", + " ACCESS_TOKEN = \"79345899-q0Yb2A2BOfNXkNEjqdFU474r8yARK2WkUqhlTYDjY\"\n", + " ACCESS_TOKEN_SECRET = \"OUD4HI3o11cc4VC2TkTcxSYWTQAcjsh2mlni3SGlkA3fy\"\n", + "\n", + "\n", + " # Intento de conexión\n", + " try: \n", + " auth = tweepy.OAuthHandler(API_KEY, API_SECRET)\n", + " auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)\n", + " global api\n", + " api = tweepy.API(auth)\n", + " return api\n", + " except: \n", + " print(\"Error: verifica tus credenciales\")" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "access_Twitter_API()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [], + "source": [ + "#Convertir a json dataframe\n", + "def get_text(json):\n", + " global texts\n", + " global df\n", + " texts = [pd.Series(i._json) for i in json]\n", + " df = pd.DataFrame(texts)\n", + " return df\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "#Buscar los mejores tweets de una serie\n", + "def get_best_tweets(serie):\n", + " try:\n", + " global best_tweets\n", + " best_tweets = api.search(q=serie, lang = 'en', count = 50, result_type='mixed')\n", + " global tweets\n", + " tweets = get_text(best_tweets)\n", + " return tweets\n", + " except tweepy.TweepError as e: \n", + " print(\"Error : \" + str(e)) " + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [], + "source": [ + "#Dejar solo texto y convertirlo a dataframe\n", + "def only_text_column(column):\n", + " global tweets_to_text\n", + " tweets_to_text = tweets['text']\n", + " global tweetsdf\n", + " tweetsdf = pd.DataFrame(tweets_to_text)\n", + " return tweetsdf\n" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [], + "source": [ + "def todo(serie):\n", + " return only_text_column(get_best_tweets(serie))" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
text
0Are you ready to venture into the great beyond...
1It's only just begun. #WatchmenHBO https://t.c...
2What DC Comics needs to learn from Joker’s suc...
3RT @Firannion: @neilhimself There needs to be ...
4RT @watchmen: Are you ready to venture into th...
5RT @Firannion: @neilhimself There needs to be ...
6RT @55mmbae: The opening scene of watchmen was...
7RT @Salon: \"Watchmen\" creator and star: This i...
8Last week's #WatchmenHBO was full of tiny deta...
9The Affair Comes to an End, Power Heads for Hi...
10RT @PAPPADEMAS: hearing Alan Moore has decided...
11RT @thelindsayellis: It’s a shame that the new...
12RT @DCComics: Who's watching @Watchmen? Dive i...
13@AkakpoJamal @watchmen @HBO You're an actual c...
14Giving Watchmen a chance.
15RT @jilevin: \"Watchmen\" creator and star: This...
16@AyeNellz_ Facts, indeed! Random question but ...
17RT @michaelharriot: Thread:\\n\\nA lot of white ...
18Are the rorschach mask supposed to represent t...
19... and that shall suffice for today. Another ...
20@Gary_Gillatt Watchmen worth a look then? I’ve...
21RT @55mmbae: The opening scene of watchmen was...
22@ReignOfApril @watchmen @HBO I’m jealous! How ...
23RT @Minxysshoes: @ReignOfApril @watchmen @HBO ...
24RT @michaelharriot: Thread:\\n\\nA lot of white ...
25RT @vitargaryen13: \"We don’t do lollipops and ...
26RT @jilevin: \"Watchmen\" creator and star: This...
27RT @jilevin: \"Watchmen\" creator and star: This...
28FINALLY watching Watchmen
29@Xo_Shereen_Xo Well I'd say \"Peaky Blinders\" i...
30Estoy viendo Watchmen 1x02 \"Martial Feats of C...
31https://t.co/EpxKLAXshI\\n\\nIf you're watching ...
32RT @jilevin: \"Watchmen\" creator and star: This...
33RT @thelindsayellis: It’s a shame that the new...
34@StuGilmore Did you see the Watchmen series ye...
35\"Watchmen\" creator and star: This is America's...
36RT @watchmen: \"Breathtaking, first class enter...
37\"Watchmen\" creator and star: This is America's...
38RT @watchmen: Are you ready to venture into th...
39We ready for watchmen tonight !?!?
40RT @SoultzKim: 😉 q is very helpful, but Our Cr...
41Watchmen is a bit fucking good innit?
42Watchmen got interrupted so now I'm on to ... ...
43Been home sick all day so I already finished a...
44it's watchmen day!!! 😎
45\"We don’t do lollipops and rainbows. Because w...
46HBO Watchmen Review: Better Than the Movie So ...
47@carigervin There’s a great website called The...
48@EWDocJensen @LByock That was an incredible ep...
49Anatomy of a Scene: How 'Watchmen' Director Ni...
\n", + "
" + ], + "text/plain": [ + " text\n", + "0 Are you ready to venture into the great beyond...\n", + "1 It's only just begun. #WatchmenHBO https://t.c...\n", + "2 What DC Comics needs to learn from Joker’s suc...\n", + "3 RT @Firannion: @neilhimself There needs to be ...\n", + "4 RT @watchmen: Are you ready to venture into th...\n", + "5 RT @Firannion: @neilhimself There needs to be ...\n", + "6 RT @55mmbae: The opening scene of watchmen was...\n", + "7 RT @Salon: \"Watchmen\" creator and star: This i...\n", + "8 Last week's #WatchmenHBO was full of tiny deta...\n", + "9 The Affair Comes to an End, Power Heads for Hi...\n", + "10 RT @PAPPADEMAS: hearing Alan Moore has decided...\n", + "11 RT @thelindsayellis: It’s a shame that the new...\n", + "12 RT @DCComics: Who's watching @Watchmen? Dive i...\n", + "13 @AkakpoJamal @watchmen @HBO You're an actual c...\n", + "14 Giving Watchmen a chance.\n", + "15 RT @jilevin: \"Watchmen\" creator and star: This...\n", + "16 @AyeNellz_ Facts, indeed! Random question but ...\n", + "17 RT @michaelharriot: Thread:\\n\\nA lot of white ...\n", + "18 Are the rorschach mask supposed to represent t...\n", + "19 ... and that shall suffice for today. Another ...\n", + "20 @Gary_Gillatt Watchmen worth a look then? I’ve...\n", + "21 RT @55mmbae: The opening scene of watchmen was...\n", + "22 @ReignOfApril @watchmen @HBO I’m jealous! How ...\n", + "23 RT @Minxysshoes: @ReignOfApril @watchmen @HBO ...\n", + "24 RT @michaelharriot: Thread:\\n\\nA lot of white ...\n", + "25 RT @vitargaryen13: \"We don’t do lollipops and ...\n", + "26 RT @jilevin: \"Watchmen\" creator and star: This...\n", + "27 RT @jilevin: \"Watchmen\" creator and star: This...\n", + "28 FINALLY watching Watchmen\n", + "29 @Xo_Shereen_Xo Well I'd say \"Peaky Blinders\" i...\n", + "30 Estoy viendo Watchmen 1x02 \"Martial Feats of C...\n", + "31 https://t.co/EpxKLAXshI\\n\\nIf you're watching ...\n", + "32 RT @jilevin: \"Watchmen\" creator and star: This...\n", + "33 RT @thelindsayellis: It’s a shame that the new...\n", + "34 @StuGilmore Did you see the Watchmen series ye...\n", + "35 \"Watchmen\" creator and star: This is America's...\n", + "36 RT @watchmen: \"Breathtaking, first class enter...\n", + "37 \"Watchmen\" creator and star: This is America's...\n", + "38 RT @watchmen: Are you ready to venture into th...\n", + "39 We ready for watchmen tonight !?!?\n", + "40 RT @SoultzKim: 😉 q is very helpful, but Our Cr...\n", + "41 Watchmen is a bit fucking good innit?\n", + "42 Watchmen got interrupted so now I'm on to ... ...\n", + "43 Been home sick all day so I already finished a...\n", + "44 it's watchmen day!!! 😎\n", + "45 \"We don’t do lollipops and rainbows. Because w...\n", + "46 HBO Watchmen Review: Better Than the Movie So ...\n", + "47 @carigervin There’s a great website called The...\n", + "48 @EWDocJensen @LByock That was an incredible ep...\n", + "49 Anatomy of a Scene: How 'Watchmen' Director Ni..." + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list1 = todo(top5df.iloc[0]['Name'])\n", + "list1\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Esto no sale :( y no sé por qué porque con list1 sí sale, pero con las otras ya no. \n", + "list1,list2,list3,list4,list5 = top5df['Name'].apply(todo)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [], + "source": [ + "#función para clasificar tweets\n", + "def get_tweet_sentiment(tweet): \n", + " ''' \n", + " Utility function to classify sentiment of passed tweet \n", + " using textblob's sentiment method \n", + " '''\n", + " # create TextBlob object of passed tweet text \n", + " analysis = TextBlob(tweet) \n", + " # set sentiment \n", + " if analysis.sentiment.polarity > 0: \n", + " return 'positive'\n", + " elif analysis.sentiment.polarity == 0: \n", + " return 'neutral'\n", + " else: \n", + " return 'negative'" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [], + "source": [ + "#Aplicar sentimientos a todo\n", + "sentiments = tweetsdf['text'].apply(get_tweet_sentiment)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
textsentiments
0Are you ready to venture into the great beyond...positive
1It's only just begun. #WatchmenHBO https://t.c...neutral
2What DC Comics needs to learn from Joker’s suc...positive
3RT @Firannion: @neilhimself There needs to be ...positive
4RT @watchmen: Are you ready to venture into th...positive
5RT @Firannion: @neilhimself There needs to be ...positive
6RT @55mmbae: The opening scene of watchmen was...neutral
7RT @Salon: \"Watchmen\" creator and star: This i...negative
8Last week's #WatchmenHBO was full of tiny deta...negative
9The Affair Comes to an End, Power Heads for Hi...positive
10RT @PAPPADEMAS: hearing Alan Moore has decided...negative
11RT @thelindsayellis: It’s a shame that the new...positive
12RT @DCComics: Who's watching @Watchmen? Dive i...negative
13@AkakpoJamal @watchmen @HBO You're an actual c...positive
14Giving Watchmen a chance.neutral
15RT @jilevin: \"Watchmen\" creator and star: This...negative
16@AyeNellz_ Facts, indeed! Random question but ...negative
17RT @michaelharriot: Thread:\\n\\nA lot of white ...negative
18Are the rorschach mask supposed to represent t...neutral
19... and that shall suffice for today. Another ...positive
20@Gary_Gillatt Watchmen worth a look then? I’ve...positive
21RT @55mmbae: The opening scene of watchmen was...neutral
22@ReignOfApril @watchmen @HBO I’m jealous! How ...positive
23RT @Minxysshoes: @ReignOfApril @watchmen @HBO ...neutral
24RT @michaelharriot: Thread:\\n\\nA lot of white ...negative
25RT @vitargaryen13: \"We don’t do lollipops and ...positive
26RT @jilevin: \"Watchmen\" creator and star: This...negative
27RT @jilevin: \"Watchmen\" creator and star: This...negative
28FINALLY watching Watchmenneutral
29@Xo_Shereen_Xo Well I'd say \"Peaky Blinders\" i...positive
30Estoy viendo Watchmen 1x02 \"Martial Feats of C...neutral
31https://t.co/EpxKLAXshI\\n\\nIf you're watching ...positive
32RT @jilevin: \"Watchmen\" creator and star: This...negative
33RT @thelindsayellis: It’s a shame that the new...positive
34@StuGilmore Did you see the Watchmen series ye...neutral
35\"Watchmen\" creator and star: This is America's...negative
36RT @watchmen: \"Breathtaking, first class enter...positive
37\"Watchmen\" creator and star: This is America's...negative
38RT @watchmen: Are you ready to venture into th...positive
39We ready for watchmen tonight !?!?positive
40RT @SoultzKim: 😉 q is very helpful, but Our Cr...positive
41Watchmen is a bit fucking good innit?positive
42Watchmen got interrupted so now I'm on to ... ...neutral
43Been home sick all day so I already finished a...negative
44it's watchmen day!!! 😎neutral
45\"We don’t do lollipops and rainbows. Because w...positive
46HBO Watchmen Review: Better Than the Movie So ...positive
47@carigervin There’s a great website called The...positive
48@EWDocJensen @LByock That was an incredible ep...positive
49Anatomy of a Scene: How 'Watchmen' Director Ni...neutral
\n", + "
" + ], + "text/plain": [ + " text sentiments\n", + "0 Are you ready to venture into the great beyond... positive\n", + "1 It's only just begun. #WatchmenHBO https://t.c... neutral\n", + "2 What DC Comics needs to learn from Joker’s suc... positive\n", + "3 RT @Firannion: @neilhimself There needs to be ... positive\n", + "4 RT @watchmen: Are you ready to venture into th... positive\n", + "5 RT @Firannion: @neilhimself There needs to be ... positive\n", + "6 RT @55mmbae: The opening scene of watchmen was... neutral\n", + "7 RT @Salon: \"Watchmen\" creator and star: This i... negative\n", + "8 Last week's #WatchmenHBO was full of tiny deta... negative\n", + "9 The Affair Comes to an End, Power Heads for Hi... positive\n", + "10 RT @PAPPADEMAS: hearing Alan Moore has decided... negative\n", + "11 RT @thelindsayellis: It’s a shame that the new... positive\n", + "12 RT @DCComics: Who's watching @Watchmen? Dive i... negative\n", + "13 @AkakpoJamal @watchmen @HBO You're an actual c... positive\n", + "14 Giving Watchmen a chance. neutral\n", + "15 RT @jilevin: \"Watchmen\" creator and star: This... negative\n", + "16 @AyeNellz_ Facts, indeed! Random question but ... negative\n", + "17 RT @michaelharriot: Thread:\\n\\nA lot of white ... negative\n", + "18 Are the rorschach mask supposed to represent t... neutral\n", + "19 ... and that shall suffice for today. Another ... positive\n", + "20 @Gary_Gillatt Watchmen worth a look then? I’ve... positive\n", + "21 RT @55mmbae: The opening scene of watchmen was... neutral\n", + "22 @ReignOfApril @watchmen @HBO I’m jealous! How ... positive\n", + "23 RT @Minxysshoes: @ReignOfApril @watchmen @HBO ... neutral\n", + "24 RT @michaelharriot: Thread:\\n\\nA lot of white ... negative\n", + "25 RT @vitargaryen13: \"We don’t do lollipops and ... positive\n", + "26 RT @jilevin: \"Watchmen\" creator and star: This... negative\n", + "27 RT @jilevin: \"Watchmen\" creator and star: This... negative\n", + "28 FINALLY watching Watchmen neutral\n", + "29 @Xo_Shereen_Xo Well I'd say \"Peaky Blinders\" i... positive\n", + "30 Estoy viendo Watchmen 1x02 \"Martial Feats of C... neutral\n", + "31 https://t.co/EpxKLAXshI\\n\\nIf you're watching ... positive\n", + "32 RT @jilevin: \"Watchmen\" creator and star: This... negative\n", + "33 RT @thelindsayellis: It’s a shame that the new... positive\n", + "34 @StuGilmore Did you see the Watchmen series ye... neutral\n", + "35 \"Watchmen\" creator and star: This is America's... negative\n", + "36 RT @watchmen: \"Breathtaking, first class enter... positive\n", + "37 \"Watchmen\" creator and star: This is America's... negative\n", + "38 RT @watchmen: Are you ready to venture into th... positive\n", + "39 We ready for watchmen tonight !?!? positive\n", + "40 RT @SoultzKim: 😉 q is very helpful, but Our Cr... positive\n", + "41 Watchmen is a bit fucking good innit? positive\n", + "42 Watchmen got interrupted so now I'm on to ... ... neutral\n", + "43 Been home sick all day so I already finished a... negative\n", + "44 it's watchmen day!!! 😎 neutral\n", + "45 \"We don’t do lollipops and rainbows. Because w... positive\n", + "46 HBO Watchmen Review: Better Than the Movie So ... positive\n", + "47 @carigervin There’s a great website called The... positive\n", + "48 @EWDocJensen @LByock That was an incredible ep... positive\n", + "49 Anatomy of a Scene: How 'Watchmen' Director Ni... neutral" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Asignar resultado al dataframe\n", + "tweetsdf['sentiments'] = sentiments" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [], + "source": [ + "def get_positive_percentages(column):\n", + " global ltweets\n", + " ltweets = len(column)\n", + " \n", + " # picking positive tweets from column \n", + " global ptweets\n", + " ptweets = [tweet for tweet in column if tweet == 'positive']\n", + " global lptweets\n", + " lptweets = len(ptweets)\n", + " global percentagePos\n", + " percentagePos = 100*len(ptweets)/ltweets\n", + " \n", + " # percentage of positive tweets \n", + " return(\"Positive tweets percentage: {} %\".format(100*len(ptweets)/ltweets)) \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [], + "source": [ + "def get_negative_percentages(column):\n", + " global lntweets\n", + " ltweets = len(column)\n", + " \n", + " # picking negative tweets from column \n", + " global ntweets\n", + " ntweets = [tweet for tweet in column if tweet == 'negative'] \n", + " global lntweets\n", + " lntweets = len(ntweets)\n", + " global percentageNeg\n", + " percentageNeg = 100*len(ntweets)/ltweets\n", + " \n", + " # percentage of negative tweets \n", + " return(\"Negative tweets percentage: {} %\".format(100*len(ntweets)/ltweets)) " + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Negative tweets percentage: 28.0 %'" + ] + }, + "execution_count": 92, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "get_negative_percentages(tweetsdf['sentiments'])" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Positive tweets percentage: 48.0 %'" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "get_positive_percentages(tweetsdf['sentiments'])" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [], + "source": [ + "#La idea es que cada serie tenga el score y al lado el porcentaje de tweets postivos y tweets negativos\n", + "#para ver si había una relación, pero no me dio la vida ni el cerebro para hacerlo para cada serie porque mi \n", + "#apply no jaló y ya no quería llorar.\n", + "\n", + "top5df['% tweets positivos'] = percentagePos" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [], + "source": [ + "top5df['% tweets negativos'] = percentageNeg" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
NameScore% tweets positivos% tweets negativos
0Watchmen6.848.028.0
1Cómo vivir contigo mismo7.448.028.0
2Peaky Blinders8.848.028.0
3The Walking Dead8.348.028.0
4Modern Love8.148.028.0
5American Horror Story8.148.028.0
\n", + "
" + ], + "text/plain": [ + " Name Score % tweets positivos % tweets negativos\n", + "0 Watchmen 6.8 48.0 28.0\n", + "1 Cómo vivir contigo mismo 7.4 48.0 28.0\n", + "2 Peaky Blinders 8.8 48.0 28.0\n", + "3 The Walking Dead 8.3 48.0 28.0\n", + "4 Modern Love 8.1 48.0 28.0\n", + "5 American Horror Story 8.1 48.0 28.0" + ] + }, + "execution_count": 94, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Ejemplo a medias de cómo sería la tabla final.\n", + "top5df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}