This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
# In[1]: | |
# Importamos la librería pandas y le ponemos el alias pd | |
import pandas as pd | |
import matplotlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Obtenemos los datos de la pivot table y los graficamos | |
axes = table.plot(kind='bar', rot=15) | |
#Leyendas en los ejes | |
axes.set_ylabel('Millones de pruebas realizadas') | |
axes.set_xlabel('Países') | |
#Cambiamos escala en Y | |
axes.set_ylim(0,7000000) | |
fig = axes.get_figure() | |
#Cambiamos tamaño de gráfica |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hacemos que la columna Entity sea un índice | |
f_2 = filtered.set_index('Entity') | |
# Volvemos a filtrar, pero ahora los países potencia junto con México | |
power_countries = f_2.loc[ ['Mexico', 'United States' , | |
'United Kingdom', 'Russia', | |
'South Korea'] ] | |
#Creamos una Pivot table que sume todas las pruebas de cada país | |
table = pd.pivot_table( | |
power_countries, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Para hacer una copia y no modificar el dataframe original | |
from copy import copy | |
# Para que las gráficas se vean coquetas xP | |
import seaborn as sns | |
sns.set() | |
#Clonamos content_file | |
aux = copy(content_file) | |
#Obtenemos la fecha inicial del análisis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Importamos la clase datetime | |
from datetime import datetime, timedelta | |
#Convertimos la columna Date a tipo datetime, para que la podamos manipular. | |
content_file['Date'] = content_file['Date'].apply( lambda x: datetime.strptime( x, '%b %d, %Y' ) ) | |
#Mostramos los países que se incluyen en los datos | |
content_file['Entity'].unique() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importamos la librería pandas y le ponemos el alias pd | |
import pandas as pd | |
# Leemos el archivo CSV con los datos a analizar | |
content_file = pd.read_csv('full-list-covid-19-tests-per-day.csv') | |
# Si ponemos las variables o procesos en linea al final del bloque | |
# del jupyter notebook nos imprimirá en pantalla el resultado | |
content_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymysql | |
#Es la clase que emplearemos para conectarnos a la base de datos. | |
class Bd(): | |
#Constructor de nuestro conector a la base de datos. | |
def __init__(self,database, hostname='localhost', username='root', password=''): | |
self.hostname=hostname; self.username=username; self.password=password; self.database=database | |
#Declaramos el método que emplearemos para obtener los datos de la base de datos. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m venv env | |
env\Scripts\activate.bat | |
pip install -r requirements.txt | |
deactivate | |
SET FLASK_APP=application.py | |
SET FLASK_ENV=development | |
FLASK run --cert=adhoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
click==7.1.1 | |
Flask==1.1.2 | |
Flask-Cors==3.0.8 | |
Flask-JWT-Extended==3.24.1 | |
itsdangerous==1.1.0 | |
Jinja2==2.11.2 | |
MarkupSafe==1.1.1 | |
Werkzeug==1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/iangelmx/flask-azure-template.git |
NewerOlder