-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
South Korea dataset module #45
Open
cgomez9
wants to merge
3
commits into
CoronaWhy:master
Choose a base branch
from
cgomez9:south_korea_granular
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 @@ | ||
from task_geo.data_sources.covid.south_korea.kr_covid import kr_covid | ||
|
||
__all__ = ['kr_covid'] |
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,24 @@ | ||
import argparse | ||
|
||
from kr_covid import kr_covid | ||
|
||
def get_argparser(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument( | ||
'-o', '--output', required=True, | ||
help='Destination file to store the processed dataset.') | ||
|
||
return parser | ||
|
||
|
||
def main(): | ||
parser = get_argparser() | ||
args = parser.parse_args() | ||
|
||
dataset = kr_covid() | ||
dataset.to_csv(args.output, index=False, header=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import io | ||
import pandas as pd | ||
import requests | ||
|
||
|
||
def kr_covid_connector(): | ||
"""Retrieves data from south_korea_patients. | ||
|
||
Arguments: | ||
url(string): Dataset url | ||
Returns: | ||
pandas.DataFrame | ||
""" | ||
url = 'https://raw.githubusercontent.com/KrSuma/COVID19_Kr/master/Datasets/PatientInfo.csv' | ||
csv = requests.get('url').content | ||
return pd.read_csv(io.StringIO(csv.decode('utf-8'))) | ||
|
||
|
||
def kr_covid_formatter(df): | ||
"""Formats data retrieved from south_korea_patients. | ||
|
||
Arguments: | ||
df(pandas.DataFrame): | ||
|
||
Returns: | ||
pandas.DataFrame | ||
""" | ||
cols_ordered = [ | ||
'country', 'state', 'province', 'confirmed_date', | ||
'released_date', 'deceased_date', 'exposure_start', | ||
'exposure_end', 'global_id', 'birth_year', | ||
'local_id', 'sex', 'disease', | ||
'group', 'infection_reason', 'infection_order', | ||
'infected_by', 'contact_number' | ||
] | ||
df = df.reindex(columns=cols_ordered) | ||
date_columns = ['confirmed_date', 'release_date', 'deceased_date', 'exposure_start', | ||
'exposure_end'] | ||
df[date_columns] = df[date_columns].apply(pd.to_datetime()) | ||
|
||
# df['confirmed_date'] = pd.to_datetime(df.confirmed_date) | ||
# df['released_date'] = pd.to_datetime(df.released_date) | ||
# df['deceased_date'] = pd.to_datetime(df.deceased_date) | ||
# df['exposure_start'] = pd.to_datetime(df.exposure_start) | ||
# df['exposure_end'] = pd.to_datetime(df.exposure_end) | ||
return df | ||
|
||
|
||
def kr_covid(): | ||
"""Data Source for south_korea_patients. | ||
|
||
Arguments: | ||
url(string): Dataset url | ||
|
||
Returns: | ||
pandas.DataFrame | ||
""" | ||
data = kr_covid_connector() | ||
return kr_covid_formatter(data) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm totally fine with you updating the
.gitignore
with required files, but adding your personal IDE files is considered a bad practice, you can see how to move this contents into a global.gitignore
file for your local installation here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.gitignore
has been updated.also,
audit.md
anddatapackage.json
will be added too.also, didnt notice the
PULL_REQUEST_TEMPLATE.md
, so ill take a look into it! thanks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, I didn't know you can set a global gitignore thank you @ManuelAlvarezC !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ManuelAlvarezC Could you elaborate on the
audit.md
and thedatapackage.json
? just this two left.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although is not as complete as it should be, thedocumentation will help you get a good grab on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ManuelAlvarezC Thank you, ill take a look at it, finalize the edit and make the push.