|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "<a href=\"https://colab.research.google.com/github/fralfaro/MAT281/blob/main/docs/labs/lab_05.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n", |
| 8 | + "\n", |
| 9 | + "\n", |
| 10 | + "# MAT281 - Laboratorio N°05\n", |
| 11 | + "\n" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "metadata": {}, |
| 17 | + "source": [ |
| 18 | + "\n", |
| 19 | + "\n", |
| 20 | + "**Objetivo**: Explorar y visualizar datos de Netflix usando **matplotlib** y **seaborn/plotly**, aprendiendo a elegir gráficos adecuados para distintos tipos de variables y preguntas de análisis.\n", |
| 21 | + "\n", |
| 22 | + "\n", |
| 23 | + "\n", |
| 24 | + "**Dataset**: \n", |
| 25 | + "\n", |
| 26 | + "Trabajaremos con el archivo `netflix_titles.csv`, que contiene información sobre los títulos disponibles en la plataforma Netflix hasta el año 2021.\n", |
| 27 | + "\n", |
| 28 | + "| Variable | Clase | Descripción |\n", |
| 29 | + "|----------------|-----------|------------------------------------------------------------------------------|\n", |
| 30 | + "| show_id | caracter | Identificador único del título en el catálogo de Netflix. |\n", |
| 31 | + "| type | caracter | Tipo de contenido: 'Movie' o 'TV Show'. |\n", |
| 32 | + "| title | caracter | Título del contenido. |\n", |
| 33 | + "| director | caracter | Nombre del director (puede ser nulo). |\n", |
| 34 | + "| cast | caracter | Lista de actores principales (puede ser nulo). |\n", |
| 35 | + "| country | caracter | País o países donde se produjo el contenido. |\n", |
| 36 | + "| date_added | fecha | Fecha en la que el título fue agregado al catálogo de Netflix. |\n", |
| 37 | + "| release_year | entero | Año de lanzamiento original del título. |\n", |
| 38 | + "| rating | caracter | Clasificación por edad (por ejemplo: 'PG-13', 'TV-MA'). |\n", |
| 39 | + "| duration | caracter | Duración del contenido (minutos o número de temporadas para series). |\n", |
| 40 | + "| listed_in | caracter | Categorías o géneros en los que está clasificado el contenido. |\n", |
| 41 | + "| description | caracter | Breve sinopsis del contenido. |\n", |
| 42 | + "\n", |
| 43 | + "\n" |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "cell_type": "code", |
| 48 | + "execution_count": 4, |
| 49 | + "metadata": {}, |
| 50 | + "outputs": [], |
| 51 | + "source": [ |
| 52 | + "import pandas as pd\n", |
| 53 | + "import seaborn as sns\n", |
| 54 | + "import matplotlib.pyplot as plt\n", |
| 55 | + "\n", |
| 56 | + "sns.set_theme(style=\"whitegrid\")" |
| 57 | + ] |
| 58 | + }, |
| 59 | + { |
| 60 | + "cell_type": "code", |
| 61 | + "execution_count": 5, |
| 62 | + "metadata": {}, |
| 63 | + "outputs": [ |
| 64 | + { |
| 65 | + "data": { |
| 66 | + "text/html": [ |
| 67 | + "<div>\n", |
| 68 | + "<style scoped>\n", |
| 69 | + " .dataframe tbody tr th:only-of-type {\n", |
| 70 | + " vertical-align: middle;\n", |
| 71 | + " }\n", |
| 72 | + "\n", |
| 73 | + " .dataframe tbody tr th {\n", |
| 74 | + " vertical-align: top;\n", |
| 75 | + " }\n", |
| 76 | + "\n", |
| 77 | + " .dataframe thead th {\n", |
| 78 | + " text-align: right;\n", |
| 79 | + " }\n", |
| 80 | + "</style>\n", |
| 81 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 82 | + " <thead>\n", |
| 83 | + " <tr style=\"text-align: right;\">\n", |
| 84 | + " <th></th>\n", |
| 85 | + " <th>show_id</th>\n", |
| 86 | + " <th>type</th>\n", |
| 87 | + " <th>title</th>\n", |
| 88 | + " <th>director</th>\n", |
| 89 | + " <th>cast</th>\n", |
| 90 | + " <th>country</th>\n", |
| 91 | + " <th>date_added</th>\n", |
| 92 | + " <th>release_year</th>\n", |
| 93 | + " <th>rating</th>\n", |
| 94 | + " <th>duration</th>\n", |
| 95 | + " <th>listed_in</th>\n", |
| 96 | + " <th>description</th>\n", |
| 97 | + " </tr>\n", |
| 98 | + " </thead>\n", |
| 99 | + " <tbody>\n", |
| 100 | + " <tr>\n", |
| 101 | + " <th>0</th>\n", |
| 102 | + " <td>s1</td>\n", |
| 103 | + " <td>Movie</td>\n", |
| 104 | + " <td>Dick Johnson Is Dead</td>\n", |
| 105 | + " <td>Kirsten Johnson</td>\n", |
| 106 | + " <td>NaN</td>\n", |
| 107 | + " <td>United States</td>\n", |
| 108 | + " <td>September 25, 2021</td>\n", |
| 109 | + " <td>2020</td>\n", |
| 110 | + " <td>PG-13</td>\n", |
| 111 | + " <td>90 min</td>\n", |
| 112 | + " <td>Documentaries</td>\n", |
| 113 | + " <td>As her father nears the end of his life, filmm...</td>\n", |
| 114 | + " </tr>\n", |
| 115 | + " <tr>\n", |
| 116 | + " <th>1</th>\n", |
| 117 | + " <td>s2</td>\n", |
| 118 | + " <td>TV Show</td>\n", |
| 119 | + " <td>Blood & Water</td>\n", |
| 120 | + " <td>NaN</td>\n", |
| 121 | + " <td>Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban...</td>\n", |
| 122 | + " <td>South Africa</td>\n", |
| 123 | + " <td>September 24, 2021</td>\n", |
| 124 | + " <td>2021</td>\n", |
| 125 | + " <td>TV-MA</td>\n", |
| 126 | + " <td>2 Seasons</td>\n", |
| 127 | + " <td>International TV Shows, TV Dramas, TV Mysteries</td>\n", |
| 128 | + " <td>After crossing paths at a party, a Cape Town t...</td>\n", |
| 129 | + " </tr>\n", |
| 130 | + " <tr>\n", |
| 131 | + " <th>2</th>\n", |
| 132 | + " <td>s3</td>\n", |
| 133 | + " <td>TV Show</td>\n", |
| 134 | + " <td>Ganglands</td>\n", |
| 135 | + " <td>Julien Leclercq</td>\n", |
| 136 | + " <td>Sami Bouajila, Tracy Gotoas, Samuel Jouy, Nabi...</td>\n", |
| 137 | + " <td>NaN</td>\n", |
| 138 | + " <td>September 24, 2021</td>\n", |
| 139 | + " <td>2021</td>\n", |
| 140 | + " <td>TV-MA</td>\n", |
| 141 | + " <td>1 Season</td>\n", |
| 142 | + " <td>Crime TV Shows, International TV Shows, TV Act...</td>\n", |
| 143 | + " <td>To protect his family from a powerful drug lor...</td>\n", |
| 144 | + " </tr>\n", |
| 145 | + " <tr>\n", |
| 146 | + " <th>3</th>\n", |
| 147 | + " <td>s4</td>\n", |
| 148 | + " <td>TV Show</td>\n", |
| 149 | + " <td>Jailbirds New Orleans</td>\n", |
| 150 | + " <td>NaN</td>\n", |
| 151 | + " <td>NaN</td>\n", |
| 152 | + " <td>NaN</td>\n", |
| 153 | + " <td>September 24, 2021</td>\n", |
| 154 | + " <td>2021</td>\n", |
| 155 | + " <td>TV-MA</td>\n", |
| 156 | + " <td>1 Season</td>\n", |
| 157 | + " <td>Docuseries, Reality TV</td>\n", |
| 158 | + " <td>Feuds, flirtations and toilet talk go down amo...</td>\n", |
| 159 | + " </tr>\n", |
| 160 | + " <tr>\n", |
| 161 | + " <th>4</th>\n", |
| 162 | + " <td>s5</td>\n", |
| 163 | + " <td>TV Show</td>\n", |
| 164 | + " <td>Kota Factory</td>\n", |
| 165 | + " <td>NaN</td>\n", |
| 166 | + " <td>Mayur More, Jitendra Kumar, Ranjan Raj, Alam K...</td>\n", |
| 167 | + " <td>India</td>\n", |
| 168 | + " <td>September 24, 2021</td>\n", |
| 169 | + " <td>2021</td>\n", |
| 170 | + " <td>TV-MA</td>\n", |
| 171 | + " <td>2 Seasons</td>\n", |
| 172 | + " <td>International TV Shows, Romantic TV Shows, TV ...</td>\n", |
| 173 | + " <td>In a city of coaching centers known to train I...</td>\n", |
| 174 | + " </tr>\n", |
| 175 | + " </tbody>\n", |
| 176 | + "</table>\n", |
| 177 | + "</div>" |
| 178 | + ], |
| 179 | + "text/plain": [ |
| 180 | + " show_id type title director \\\n", |
| 181 | + "0 s1 Movie Dick Johnson Is Dead Kirsten Johnson \n", |
| 182 | + "1 s2 TV Show Blood & Water NaN \n", |
| 183 | + "2 s3 TV Show Ganglands Julien Leclercq \n", |
| 184 | + "3 s4 TV Show Jailbirds New Orleans NaN \n", |
| 185 | + "4 s5 TV Show Kota Factory NaN \n", |
| 186 | + "\n", |
| 187 | + " cast country \\\n", |
| 188 | + "0 NaN United States \n", |
| 189 | + "1 Ama Qamata, Khosi Ngema, Gail Mabalane, Thaban... South Africa \n", |
| 190 | + "2 Sami Bouajila, Tracy Gotoas, Samuel Jouy, Nabi... NaN \n", |
| 191 | + "3 NaN NaN \n", |
| 192 | + "4 Mayur More, Jitendra Kumar, Ranjan Raj, Alam K... India \n", |
| 193 | + "\n", |
| 194 | + " date_added release_year rating duration \\\n", |
| 195 | + "0 September 25, 2021 2020 PG-13 90 min \n", |
| 196 | + "1 September 24, 2021 2021 TV-MA 2 Seasons \n", |
| 197 | + "2 September 24, 2021 2021 TV-MA 1 Season \n", |
| 198 | + "3 September 24, 2021 2021 TV-MA 1 Season \n", |
| 199 | + "4 September 24, 2021 2021 TV-MA 2 Seasons \n", |
| 200 | + "\n", |
| 201 | + " listed_in \\\n", |
| 202 | + "0 Documentaries \n", |
| 203 | + "1 International TV Shows, TV Dramas, TV Mysteries \n", |
| 204 | + "2 Crime TV Shows, International TV Shows, TV Act... \n", |
| 205 | + "3 Docuseries, Reality TV \n", |
| 206 | + "4 International TV Shows, Romantic TV Shows, TV ... \n", |
| 207 | + "\n", |
| 208 | + " description \n", |
| 209 | + "0 As her father nears the end of his life, filmm... \n", |
| 210 | + "1 After crossing paths at a party, a Cape Town t... \n", |
| 211 | + "2 To protect his family from a powerful drug lor... \n", |
| 212 | + "3 Feuds, flirtations and toilet talk go down amo... \n", |
| 213 | + "4 In a city of coaching centers known to train I... " |
| 214 | + ] |
| 215 | + }, |
| 216 | + "execution_count": 5, |
| 217 | + "metadata": {}, |
| 218 | + "output_type": "execute_result" |
| 219 | + } |
| 220 | + ], |
| 221 | + "source": [ |
| 222 | + "# Cargar datos\n", |
| 223 | + "df = pd.read_csv('https://raw.githubusercontent.com/fralfaro/MAT281/main/docs/labs/data/netflix_titles.csv')\n", |
| 224 | + "df.head()" |
| 225 | + ] |
| 226 | + }, |
| 227 | + { |
| 228 | + "cell_type": "markdown", |
| 229 | + "metadata": {}, |
| 230 | + "source": [ |
| 231 | + "## 📊 Parte 1: Exploración visual básica\n", |
| 232 | + "\n", |
| 233 | + "1. **Distribución de tipos de contenido**\n", |
| 234 | + "\n", |
| 235 | + " * Realiza un gráfico de barras mostrando la cantidad de películas vs series (`type`).\n", |
| 236 | + " * Pregunta guía: ¿Cuál es el tipo de contenido predominante en Netflix? ¿Qué implicancias podría tener para los usuarios?\n", |
| 237 | + "\n", |
| 238 | + "2. **Histograma de años de lanzamiento**\n", |
| 239 | + "\n", |
| 240 | + " * Muestra cómo se distribuyen los títulos según su `release_year`.\n", |
| 241 | + " * Pregunta guía: ¿Hay más contenido reciente o antiguo? ¿Notas algún patrón en décadas específicas?\n", |
| 242 | + "\n", |
| 243 | + "3. **Proporción de clasificaciones por edad (`rating`)**\n", |
| 244 | + "\n", |
| 245 | + " * Haz un gráfico circular o de barras.\n", |
| 246 | + " * Pregunta guía: ¿Qué clasificación es más común? ¿Crees que Netflix está más enfocado en público adulto, familiar o infantil?\n", |
| 247 | + "\n" |
| 248 | + ] |
| 249 | + }, |
| 250 | + { |
| 251 | + "cell_type": "code", |
| 252 | + "execution_count": null, |
| 253 | + "metadata": {}, |
| 254 | + "outputs": [], |
| 255 | + "source": [ |
| 256 | + "# FIXME" |
| 257 | + ] |
| 258 | + }, |
| 259 | + { |
| 260 | + "cell_type": "markdown", |
| 261 | + "metadata": {}, |
| 262 | + "source": [ |
| 263 | + "\n", |
| 264 | + "\n", |
| 265 | + "## 🎨 Parte 2: Tendencias y evolución en el tiempo\n", |
| 266 | + "\n", |
| 267 | + "4. **Número de títulos agregados por año**\n", |
| 268 | + "\n", |
| 269 | + " * Usa `date_added` (convertido a fecha) y grafica una serie temporal.\n", |
| 270 | + " * Pregunta guía: ¿Cuándo creció más el catálogo de Netflix? ¿Qué relación podría tener con la expansión internacional de la plataforma?\n", |
| 271 | + "\n", |
| 272 | + "5. **Heatmap de lanzamientos por año y mes**\n", |
| 273 | + "\n", |
| 274 | + " * Construye un mapa de calor con `year_added` y `month_added`.\n", |
| 275 | + " * Pregunta guía: ¿Hay meses con más estrenos que otros? ¿Qué conclusiones puedes sacar sobre la estacionalidad de lanzamientos?\n", |
| 276 | + "\n", |
| 277 | + "6. **Duración de películas por género**\n", |
| 278 | + "\n", |
| 279 | + " * Extrae la duración en minutos y crea un boxplot agrupado por género principal.\n", |
| 280 | + " * Pregunta guía: ¿Qué géneros suelen durar más? ¿Qué podrías decir sobre la variabilidad dentro de un mismo género?\n" |
| 281 | + ] |
| 282 | + }, |
| 283 | + { |
| 284 | + "cell_type": "code", |
| 285 | + "execution_count": 5, |
| 286 | + "metadata": {}, |
| 287 | + "outputs": [], |
| 288 | + "source": [ |
| 289 | + "# FIXME" |
| 290 | + ] |
| 291 | + }, |
| 292 | + { |
| 293 | + "cell_type": "markdown", |
| 294 | + "metadata": {}, |
| 295 | + "source": [ |
| 296 | + "\n", |
| 297 | + "\n", |
| 298 | + "## 🔥 Parte 3: Comparaciones y relaciones\n", |
| 299 | + "\n", |
| 300 | + "7. **Top 10 países con más producciones**\n", |
| 301 | + "\n", |
| 302 | + " * Usa un gráfico de barras para mostrar los países más frecuentes en la columna `country`.\n", |
| 303 | + " * Pregunta guía: ¿Qué países dominan el catálogo? ¿Sorprende la distribución o es esperada?\n", |
| 304 | + "\n", |
| 305 | + "8. **Películas vs Series según género**\n", |
| 306 | + "\n", |
| 307 | + " * Realiza un gráfico de barras apiladas para mostrar la cantidad de títulos por género, separando `Movie` y `TV Show`.\n", |
| 308 | + " * Pregunta guía: ¿Existen géneros más asociados a películas o a series?\n", |
| 309 | + "\n", |
| 310 | + "9. **Relación entre duración y año de lanzamiento**\n", |
| 311 | + "\n", |
| 312 | + " * Haz un gráfico de dispersión (scatterplot) con `release_year` en el eje X y `duration` (en minutos) en el eje Y.\n", |
| 313 | + " * Pregunta guía: ¿Han cambiado los estándares de duración de las películas con el tiempo? ¿Se ven outliers interesantes?\n", |
| 314 | + "\n" |
| 315 | + ] |
| 316 | + }, |
| 317 | + { |
| 318 | + "cell_type": "code", |
| 319 | + "execution_count": 6, |
| 320 | + "metadata": {}, |
| 321 | + "outputs": [], |
| 322 | + "source": [ |
| 323 | + "# FIXME" |
| 324 | + ] |
| 325 | + }, |
| 326 | + { |
| 327 | + "cell_type": "markdown", |
| 328 | + "metadata": {}, |
| 329 | + "source": [ |
| 330 | + "## ⭐ Desafío Final\n", |
| 331 | + "\n", |
| 332 | + "* Encuentra las combinaciones más frecuentes de **género + rating** y represéntalas en un **heatmap o gráfico de burbujas**.\n", |
| 333 | + "* Pregunta guía: ¿Qué géneros están más dirigidos a un público adulto? ¿Y cuáles a público familiar o infantil?" |
| 334 | + ] |
| 335 | + }, |
| 336 | + { |
| 337 | + "cell_type": "markdown", |
| 338 | + "metadata": {}, |
| 339 | + "source": [ |
| 340 | + "# FIXME" |
| 341 | + ] |
| 342 | + } |
| 343 | + ], |
| 344 | + "metadata": { |
| 345 | + "kernelspec": { |
| 346 | + "display_name": "docs-py3.10", |
| 347 | + "language": "python", |
| 348 | + "name": "python3" |
| 349 | + }, |
| 350 | + "language_info": { |
| 351 | + "codemirror_mode": { |
| 352 | + "name": "ipython", |
| 353 | + "version": 3 |
| 354 | + }, |
| 355 | + "file_extension": ".py", |
| 356 | + "mimetype": "text/x-python", |
| 357 | + "name": "python", |
| 358 | + "nbconvert_exporter": "python", |
| 359 | + "pygments_lexer": "ipython3", |
| 360 | + "version": "3.10.11" |
| 361 | + } |
| 362 | + }, |
| 363 | + "nbformat": 4, |
| 364 | + "nbformat_minor": 4 |
| 365 | +} |
0 commit comments