This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
85 changed files
with
2,299 additions
and
31 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import datetime | ||
import sys | ||
import os | ||
|
||
|
||
def get_iso_by_country_name(country_name, mode): | ||
|
||
array_iso = np.array(['PE-AMA', 'PE-ANC', 'PE-APU', 'PE-ARE', 'PE-AYA', 'PE-CAJ', 'PE-CAL', 'PE-CUS', 'PE-HUV', 'PE-HUC', 'PE-ICA', 'PE-JUN', | ||
'PE-LAL', 'PE-LAM', 'PE-LIM', 'PE-LOR', 'PE-MDD', 'PE-MOQ', 'PE-PAS', 'PE-PIU', 'PE-PUN', 'PE-SAM', 'PE-TAC', 'PE-TUM', 'PE-UCA']) | ||
array_peru_csv = np.array(['Amazonas', 'Ancash', 'Apurimac', 'Arequipa', 'Ayacucho', 'Cajamarca', 'Callao', 'Cusco', 'Huancavelica', 'Huánuco', 'Ica', 'Junín', | ||
'La Libertad', 'Lambayeque', 'Lima', 'Loreto', 'Madre de Dios', 'Moquegua', 'Pasco', 'Piura', 'Puno', 'San Martín', 'Tacna', 'Tumbes', 'Ucayali']) | ||
array_peru_fixed = np.array(['Amazonas', 'Ancash', 'Apurimac', 'Arequipa', 'Ayacucho', 'Cajamarca', 'Callao', 'Cusco', 'Huancavelica', 'Huanuco', 'Ica', 'Junin', | ||
'La Libertad', 'Lambayeque', 'Lima', 'Loreto', 'Madre de dios', 'Moquegua', 'Pasco', 'Piura', 'Puno', 'San Martin', 'Tacna', 'Tumbes', 'Ucayali']) | ||
|
||
df = pd.DataFrame({'ISO 3166-2 Code': array_iso, | ||
'Remote': array_peru_csv, 'Local': array_peru_fixed}) | ||
|
||
string_iso = '' | ||
|
||
if mode == 'remote': | ||
string_iso = df[df['Remote'] == | ||
country_name]['ISO 3166-2 Code'].values[0] | ||
elif mode == 'local': | ||
string_iso = df[df['Local'] == | ||
country_name]['ISO 3166-2 Code'].values[0] | ||
|
||
return string_iso | ||
|
||
|
||
def generate_list_dates(path): | ||
# Generate dates from files existing | ||
date_list_csv = [] | ||
path, dirs, files = next(os.walk(path)) | ||
numero_archivos = len(files) | ||
print('There is {} files on the path and one is README. We iterate {} times...'.format( | ||
numero_archivos, numero_archivos-1)) | ||
# dates | ||
base = (datetime.datetime.today()).date() | ||
numdays = numero_archivos-1 | ||
date_list_csv = [str(base - datetime.timedelta(days=x))+str('.csv') | ||
for x in range(numdays)] | ||
print('Adding {} dates in a list...'.format(len(date_list_csv))) | ||
date_list = [] | ||
for d in date_list_csv: | ||
date_list.append(d[:-4]) | ||
print("List of dates:", date_list) | ||
return date_list_csv, date_list | ||
|
||
|
||
def load_and_generatecsv(): | ||
|
||
today = datetime.datetime.now().strftime('%Y-%m-%d') | ||
|
||
path_dsrp_daily_reports = 'latam_covid_19_data/daily_reports/' | ||
path_peru_csv = "https://raw.githubusercontent.com/jmcastagnetto/covid-19-peru-data/master/datos/covid-19-peru-data.csv" | ||
path_dsrp = "https://raw.githubusercontent.com/DataScienceResearchPeru/covid-19_latinoamerica/master/latam_covid_19_data/daily_reports/2020-03-08.csv" | ||
path_csv="utils/scripts/data_collection/data/peru_temporal/" | ||
|
||
data_peru = pd.read_csv(path_peru_csv) | ||
data_dsrp = pd.read_csv(path_dsrp) | ||
|
||
array_dates_csv, array_dates = generate_list_dates(path_dsrp_daily_reports) | ||
|
||
for d in array_dates: | ||
|
||
temp_dsrp = data_dsrp[data_dsrp['ISO 3166-2 Code'].str.contains('PE-')] | ||
|
||
temp_dsrp['Confirmed'] = 0 | ||
temp_dsrp['Deaths'] = 0 | ||
temp_dsrp['Recovered'] = 0 | ||
# data_peru | ||
data_peru = data_peru[data_peru['date'] == d] | ||
data_peru = data_peru.fillna('') | ||
data_peru = data_peru[data_peru['region'] != ''] | ||
|
||
for row in range(len(data_peru)): | ||
numero_confirmed = data_peru.iloc[row]['confirmed'] | ||
|
||
string_iso = get_iso_by_country_name( | ||
data_peru.iloc[row]['region'], 'remote') | ||
f = temp_dsrp[temp_dsrp['ISO 3166-2 Code'] == string_iso] | ||
# print(f.index.values[0]) | ||
temp_dsrp.loc[f.index.values[0], ['Confirmed']] = numero_confirmed | ||
temp_dsrp.loc[f.index.values[0], ['Last Update']] = today | ||
|
||
temp_dsrp = temp_dsrp.fillna('') | ||
|
||
print(d, end=' - ') | ||
|
||
temp_dsrp.to_csv(path_csv+d+'.csv',index=False) | ||
|
||
|
||
if __name__ == "__main__": | ||
load_and_generatecsv() |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-02-25.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-02-26.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-02-27.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-02-28.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-02-29.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-03-01.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-03-02.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
26 changes: 26 additions & 0 deletions
26
utils/scripts/data_collection/data/peru_temporal/2020-03-03.csv
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ISO 3166-2 Code,Country,Subdivision,Last Update,Confirmed,Deaths,Recovered | ||
PE-AMA,Peru,Amazonas,,0,0,0 | ||
PE-ANC,Peru,Ancash,,0,0,0 | ||
PE-APU,Peru,Apurimac,,0,0,0 | ||
PE-ARE,Peru,Arequipa,,0,0,0 | ||
PE-AYA,Peru,Ayacucho,,0,0,0 | ||
PE-CAJ,Peru,Cajamarca,,0,0,0 | ||
PE-CAL,Peru,Callao,,0,0,0 | ||
PE-CUS,Peru,Cusco,,0,0,0 | ||
PE-HUV,Peru,Huancavelica,,0,0,0 | ||
PE-HUC,Peru,Huanuco,,0,0,0 | ||
PE-ICA,Peru,Ica,,0,0,0 | ||
PE-JUN,Peru,Junin,,0,0,0 | ||
PE-LAL,Peru,La Libertad,,0,0,0 | ||
PE-LAM,Peru,Lambayeque,,0,0,0 | ||
PE-LIM,Peru,Lima,,0,0,0 | ||
PE-LOR,Peru,Loreto,,0,0,0 | ||
PE-MDD,Peru,Madre de dios,,0,0,0 | ||
PE-MOQ,Peru,Moquegua,,0,0,0 | ||
PE-PAS,Peru,Pasco,,0,0,0 | ||
PE-PIU,Peru,Piura,,0,0,0 | ||
PE-PUN,Peru,Puno,,0,0,0 | ||
PE-SAM,Peru,San Martin,,0,0,0 | ||
PE-TAC,Peru,Tacna,,0,0,0 | ||
PE-TUM,Peru,Tumbes,,0,0,0 | ||
PE-UCA,Peru,Ucayali,,0,0,0 |
Oops, something went wrong.