Пример #1
0
def fechasmuerte(conn, tabla):
    datos = consultar(
        conn,
        f"select fecha_notificacion, count(*) as cantidad FROM {tabla} group by fecha_notificacion ORDER BY fecha_notificacion"
    )
    datos['fecha_notificacion'] = pd.to_datetime(datos['fecha_notificacion'])
    datos['fecha_notificacion'] = datos['fecha_notificacion'].dt.strftime(
        "%m-%d")
    xinf = datos['fecha_notificacion']
    yinf = datos['cantidad']
    datosm = consultar(
        conn,
        f"select fecha_muerte, count(*) as cantidad FROM {tabla} WHERE fecha_muerte IS NOT NULL GROUP BY fecha_muerte ORDER BY fecha_muerte"
    )
    datosm['fecha_muerte'] = pd.to_datetime(datosm['fecha_muerte'])
    datosm['fecha_muerte'] = datosm['fecha_muerte'].dt.strftime("%m-%d")
    xmuer = datosm['fecha_muerte']
    ymuer = datosm['cantidad']
    fig, ax = plot.subplots()
    plot.title('Curva de comparación de muertos y recuperados en el tiempo')
    ax.plot(xinf, yinf)
    ax.plot(xmuer, ymuer, 'red')
    plot.legend(['Contagiados', 'Muertos'])
    loc = ticker.MultipleLocator(base=20)
    ax.xaxis.set_major_locator(loc)
    plot.savefig("plotsColombia/Graficomuerte.png", bbox_inches='tight')
Пример #2
0
def edades(conn, tabla):
    datos = consultar(
        conn, f"select edad, count(*) as total from {tabla}  group by edad")
    fig, ax = plot.subplots()
    ax.set_ylabel('Edad')
    ax.set_xlabel('Contagios')
    ax.set_title(
        'Número de personas contagiadas por el Covid-19 según su Edad')
    ax.scatter(datos['total'], datos['edad'])
    plot.savefig("plotsColombia/Grafico_Edad.png", bbox_inches='tight')
Пример #3
0
def barras_edad(conn, tabla):
    datos = consultar(
        conn,
        f"select edad, count(*) as total from {tabla}  where recuperado ='Fallecido' group by edad"
    )
    fig, ax = plot.subplots()
    ax.set_ylabel('Fallecidos')
    ax.set_xlabel('Edad')
    ax.set_title('Personas fallecidas por el Covid-19 en Colombia por edad')
    plot.bar(datos['edad'], datos['total'])
    plot.savefig("plotsColombia/GraficoBarras_Edad_Fallecidos.png",
                 bbox_inches='tight')
Пример #4
0
def ciudad(conn, tabla):
    datos = consultar(
        conn,
        f"select municipio, count(*) as total from {tabla} where depto=='VICHADA' group by municipio"
    )
    fig, ax = plot.subplots()
    ax.set_ylabel('Ciudades')
    ax.set_xlabel('Contagios')
    ax.set_title(
        'Número de personas contagiadas por el Covid-19 en Vichada por ciudad')
    ax.scatter(datos['total'], datos['municipio'])
    plot.savefig("plotsColombia/Grafico2d_Vichada.png", bbox_inches='tight')
Пример #5
0
def localidad_fallecidos(conn, tabla):
    datos = consultar(
        conn,
        f"SELECT localidad, count(*) as cantidad FROM {tabla} WHERE localidad!='Sin dato' and estado='Fallecido' GROUP BY localidad ORDER BY cantidad"
    )
    datos.plot(x='localidad',
               y='cantidad',
               kind='barh',
               xlabel='Localidad',
               ylabel='Fallecidos',
               color='Orange')
    plot.title('Fallecidos por localidad')
    plot.savefig("plotsBogota/Graficolocalidad.png", bbox_inches='tight')
Пример #6
0
def dosd_contagiosB(conn, tabla):
    datos = consultar(
        conn,
        f"select localidad, count(*) as total from {tabla} where sexo='F' group by localidad"
    )
    fig, ax = plot.subplots()
    ax.set_ylabel('Localidades')
    ax.set_xlabel('hombres Contagiados')
    ax.set_title(
        'Número de hombres contagiados por el Covid-19 en Bogotá por localidad'
    )
    ax.scatter(datos['total'], datos['localidad'])
    plot.savefig("plotsBogota/Grafico_Locali.png", bbox_inches='tight')
Пример #7
0
def contagios(conn, tabla):
    datos = consultar(
        conn,
        f"select municipio, count(*) as total from {tabla} where depto=='RISARALDA' and  recuperado ='Fallecido' group by municipio"
    )
    fig, ax = plot.subplots()
    ax.set_ylabel('Ciudades')
    ax.set_xlabel('Fallecidos')
    ax.set_title(
        'Número de personas fallecidas por el Covid-19 en Risaralda por ciudad '
    )
    ax.scatter(datos['total'], datos['municipio'])
    plot.savefig("plotsColombia/Grafico_Depto.png", bbox_inches='tight')
Пример #8
0
def suba(conn, tabla):
    datos = consultar(
        conn,
        f"SELECT fecha_diag, count(*) as cantidad FROM {tabla} WHERE fecha_diag not null and localidad='Suba' GROUP BY fecha_diag ORDER BY fecha_diag"
    )
    datos['fecha_diag'] = pd.to_datetime(datos['fecha_diag'])
    datos['fecha_diag'] = datos['fecha_diag'].dt.strftime("%m-%d")
    datos.plot(x='fecha_diag',
               y='cantidad',
               xlabel='Tiempo',
               ylabel='Contagios',
               color='green')
    plot.title('Contagiados contra el tiempo de la localidad Suba en Bogotá')
    plot.savefig("plotsBogota/Graficocontagios.png")
Пример #9
0
def barras_rec(conn, tabla):
    datos = consultar(
        conn,
        f"select tipo_recuperacion, count(*) as total from {tabla} where tipo_recuperacion ='PCR' or tipo_recuperacion='Tiempo' group by tipo_recuperacion"
    )
    fig, ax = plot.subplots()
    ax.set_ylabel('Recuperados')
    ax.set_xlabel('Tipo de Recuperación')
    ax.set_title(
        'Personas recuperadas del Covid-19 en Colombia segun su tipo de recuperacion'
    )
    plot.bar(datos['tipo_recuperacion'], datos['total'])
    plot.savefig("plotsColombia/GraficoBarras_recuperacion.png",
                 bbox_inches='tight')
Пример #10
0
def cicular_GeneroB(conn, tabla):
    datos = consultar(
        conn,
        f"select sexo, count(*) as total from {tabla} where sexo !='f' and sexo !='m' and localidad='Kennedy'group by sexo"
    )
    fig, ax = plot.subplots(figsize=(10, 7))
    plot.title(
        "Contagios del Covid-19 según el género en la locaildad de Kennedy\n",
        fontdict={'fontsize': 15})
    ax.pie(datos['total'],
           labels=datos['sexo'],
           autopct='%1.1f%%',
           startangle=90)
    ax.axis('equal')
    plot.savefig("plotsBogota/GraficaCircular_GeneroK.png",
                 bbox_inches='tight')
Пример #11
0
def cicular_atencion(conn, tabla):
    datos = consultar(
        conn,
        f"select ubicacion_caso, count(*) as total from {tabla} where ubicacion_caso != 'CASA' and ubicacion_caso != 'Hospital UCI' group by ubicacion_caso"
    )
    fig, ax = plot.subplots(figsize=(10, 7))
    plot.title(
        "Estados de personas contagiadas por el Covid-19 en Colombia \n",
        fontdict={'fontsize': 15})
    ax.pie(datos['total'],
           labels=datos['ubicacion_caso'],
           autopct='%1.1f%%',
           startangle=90,
           normalize=True)
    ax.axis('equal')
    plot.savefig("plotsColombia/GraficaCircular_Estados.png",
                 bbox_inches='tight')
Пример #12
0
def fechas(conn, tabla):
    datos = consultar(
        conn,
        f"select fecha_notificacion, count(*) as cantidad FROM {tabla} group by fecha_notificacion ORDER BY fecha_notificacion"
    )
    datos['fecha_notificacion'] = pd.to_datetime(datos['fecha_notificacion'])
    datos['fecha_notificacion'] = datos['fecha_notificacion'].dt.strftime(
        "%m-%d")
    xinf = datos['fecha_notificacion']
    yinf = datos['cantidad']
    fig, ax = plot.subplots()
    plot.title('Curva de contagiados en el tiempo')
    ax.plot(xinf, yinf, 'green')
    plot.legend(['Contagiados'])
    loc = ticker.MultipleLocator(base=20)
    ax.xaxis.set_major_locator(loc)
    plot.savefig("plotsColombia/Graficocontagios.png", bbox_inches='tight')