text_html_output_1.png
import os

import pandas as pd

import requests

import unidecode

INPUT_DIR = './'
if os.path.split(os.path.abspath('.'))[-1] == 'src':
    INPUT_DIR = '../input'
OUTPUT_DIR = './'
if os.path.split(os.path.abspath('.'))[-1] == 'src':
    OUTPUT_DIR = '../output'
URL_OFFICIAL_DATASET = 'https://www.datos.gov.co/api/views/gt2j-8ykr/rows.csv?accessType=DOWNLOAD'
URL_SAMPLES_PROCESSED = 'https://e.infogram.com/api/live/flex/638d656c-c77b-4326-97d3-e50cb410c6ab/8188140c-8352-4994-85e3-2100a4dbd9db?'

with requests.get(URL_OFFICIAL_DATASET) as official_dataset:
    with open(os.path.join(OUTPUT_DIR, 'covid19co_official.csv'), 'wb') as dataset_file:
        dataset_file.write(official_dataset.content)

covid19co = pd.read_csv(os.path.join(OUTPUT_DIR, 'covid19co_official.csv'))
covid19co.shape

list(covid19co.columns.values)

covid19co.columns = [unidecode.unidecode(value).upper() for value in covid19co.columns]

# Update texto to title text format
for attr in covid19co.columns:
    if covid19co[attr].dtypes == 'object':
        covid19co[attr] = covid19co[attr].transform(lambda value: str(value).title())
# Show dataframe
covid19co.head()

if covid19co.isna().sum().sum() > 0:
    covid19co.fillna(value='-', inplace=True)
covid19co.head()