<jupyter_start><jupyter_text>Covid Data<jupyter_code>import pandas as pd
import numpy as np
pathData = './data/'
pathBase = pathData + 'base/'
df = pd.read_csv(pathData + 'COVID-19_mobile_apps.csv', index_col='releaseDate', parse_dates=['releaseDate','latestUpdate'])
df
def format_indexes(df):

    # Drop NaT indexes
    df_not_indexNa = df[df.index.isin(df.index.dropna())]

    # Format index with uniform datetime format
    df_index_formatted = pd.DataFrame({
        'releaseDate':[pd.to_datetime(fecha.strftime('%Y-%m-%d')) for fecha in df_not_indexNa.index],
        'name':df_not_indexNa['name'].values,
        'continents':df_not_indexNa['continents'].values,
        'geographicCoverage':df_not_indexNa['geographicCoverage'].replace(to_replace='UAE',value='ARE').values,
        'storeName':df_not_indexNa['storeName'].values,
        'status':df_not_indexNa['status'].values
    }).dropna().set_index('releaseDate').sort_index()

    return df_index_formatted

df_index_formatted = format_indexes(df)
df_index_formatted
def count_per_months(df_formated):

    # Getting releaseDate and Cant lists
    releaseDate = df_formated.index.dropna().drop_duplicates()
    releaseDate = [fecha.strftime('%Y-%m') for fecha in releaseDate]
    releaseDate = np.unique(releaseDate).tolist()
    cant = [df_formated['name'].loc[fecha].count() for fecha in releaseDate]
    
    # Building dataFrame with releaseDate and Cant lists
    count_per_month = pd.DataFrame({
        'releaseDate':releaseDate,
        'cant':cant
    }).set_index('releaseDate')

    # Print data to .csv
    #count_per_month.to_csv(pathBase + 'statistics_count_per_month.csv')

    print(count_per_month)
    print(count_per_month['cant'].values.sum())

count_per_months(df_index_formatted)
df_countryCodes = pd.read_csv(pathData + 'CountryCodes.csv')
df_countryCodes
#codes = countryCodes['alpha-3'].dropna().drop_duplicates()
#len(countryCodes['name'][countryCodes['alpha-3']=='WORLD'])
matrixCodesAndNames = np.transpose([[code,df_countryCodes['name'][df_countryCodes['alpha-3']==code].item()]
for code in df_index_formatted['geographicCoverage'].drop_duplicates().values 
if len(df_countryCodes['name'][df_countryCodes['alpha-3']==code]) > 0]).tolist()

matrixCodesAndNames[0].append('WORLD')
matrixCodesAndNames[1].append('WORLD')

df_countryCodesAndNames = pd.DataFrame({
    'geographicCoverage':matrixCodesAndNames[0],
    'country':[name.split(',')[0].split(' (')[0] for name in matrixCodesAndNames[1]]
}).set_index('geographicCoverage').sort_index()

df_countryCodesAndNames
df_joined = df_index_formatted.join(df_countryCodesAndNames, on='geographicCoverage')[['name','continents','geographicCoverage','country','storeName','status']]
df_joined
# List 1
def continents(df_joined):
    continentsList = [continent for continent in df_joined['continents'].sort_values().unique().tolist()]
    continentsList.insert(0, continentsList.pop(len(continentsList) - 1))
    '''
    df_continents = pd.DataFrame({
        'continents': continents
    }).set_index('continents')#.to_csv(pathBase + 'geographicCoverage_continents.csv')
    return df_continents.index.tolist()
    '''
    return continentsList

continentsList = continents(df_joined)#.index.tolist()
continentsList#.index[0]
# List 2
'''
pd.DataFrame({
    continent: world[-1]
}).set_index(continent).sort_index().to_csv(pathBase + 'geographicCoverage_' + continent.replace(' ','_').lower() + '.csv')

pd.DataFrame({
    df_continents.index[0]:[country for fila in world for country in fila]
}).set_index(df_continents.index[0]).sort_index().to_csv(pathBase + 'geographicCoverage_' + df_continents.index[0].replace(' ','_').lower() + '.csv')
'''
# WORLD
world = df_joined['country'][df_joined['country']!='WORLD'].dropna().drop_duplicates().sort_values().values.tolist()
world.insert(0,'ALL')
world
# Continents
countriesPerContinentList = [df_joined['country'][df_joined['continents']==continent].drop_duplicates().sort_values().values.tolist()
for continent in continentsList
if continent != 'WORLD']
countriesPerContinentList.insert(0,world)
countriesPerContinentList
from src.cargar_data import *

# Obteniendo la data desde el módulo
df = dataframe()
df[df['continents']=='WORLD']
# Recibiendo la lista de Continents y CountriesPerContinent
matrixUbicaciones = ubicaciones(df)
matrixUbicaciones
matrixUbicaciones[0] # Continents
matrixUbicaciones[1][0] # CountriesPerContinent
from src.gestor_de_data import *

# Consultando dataframe desde el módulo
df_resultante = consultar_dataframe(df, frecuency=1, movmean=3, cumulative=0)
df_resultante
df['name'].loc['2019':'2020'].resample('D').count()#.index<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1517094017094017, 'fraction_numerical': 0.00811965811965812, 'mean_word_length': 6.537842190016103, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '436948', 'license': 'MIT', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1588, 'n_words': 237, 'path': 'notebooks/main.ipynb', 'repo_name': 'da8ah/UTPL-MobileAppDataVisualizer', 'size': '4680'}