Пример #1
0
def main():
    # Create output directory in example directory
    code_path = Path(__file__)
    output_dir = code_path.with_name("output").joinpath(code_path.stem)
    output_dir.mkdir(exist_ok=True, parents=True)
    # Read JHU dataset
    jhu_file = "input/covid_19_data.csv"
    jhu_data = JHUData(jhu_file)
    # Show the cleaned data as a CSV file
    ncov_df = jhu_data.cleaned()
    ncov_df.to_csv(output_dir.joinpath("cleaned.csv"), index=False)
Пример #2
0
 def test_cleaning(self, jhu_data):
     assert isinstance(jhu_data.raw, pd.DataFrame)
     with pytest.raises(ValueError):
         jhu_data.cleaned(population=None)
     df = jhu_data.cleaned()
     assert set(df.columns) == set(Term.COLUMNS)
     assert isinstance(JHUData.from_dataframe(df), JHUData)
Пример #3
0
def main():
    # Create output directory in example directory
    code_path = Path(__file__)
    output_dir = code_path.with_name("output").joinpath(code_path.stem)
    output_dir.mkdir(exist_ok=True, parents=True)
    # Read JHU dataset
    jhu_file = "input/covid_19_data.csv"
    jhu_data = JHUData(jhu_file)
    ncov_df = jhu_data.cleaned()
    ncov_df.to_csv(output_dir.joinpath("jhu_cleaned.csv"), index=False)
    # Read Japan datset
    jpn_file = "input/covid_jpn_total.csv"
    jpn_data = CountryData(jpn_file, country="Japan")
    jpn_data.set_variables(date="Date",
                           confirmed="Positive",
                           fatal="Fatal",
                           recovered="Discharged",
                           province=None)
    jpn_df = jpn_data.cleaned()
    jpn_df.to_csv(output_dir.joinpath("jpn_cleaned.csv"), index=False)
    # Replace data in Japan with Japan-specific dataset
    jhu_data.replace(jpn_data)
    ncov_df = jhu_data.cleaned()
    ncov_df.to_csv(output_dir.joinpath("jhu_cleaned_replaced.csv"),
                   index=False)
    return ncov_df
Пример #4
0
 def test_from_dataframe(self, jhu_data):
     df = jhu_data.cleaned()
     jhu_data2 = JHUData.from_dataframe(df)
     assert set(df.columns) == set(jhu_data2.cleaned().columns)
Пример #5
0
 def test_from_dataframe(self, japan_data):
     df = japan_data.cleaned()
     jhu_data_df = JHUData.from_dataframe(df, directory="input_dir")
     assert isinstance(jhu_data_df, JHUData)
     assert jhu_data_df.directory == "input_dir"
     jhu_data_df.records("Japan")
Пример #6
0
 def test_from_dataframe(self, japan_data):
     df = japan_data.cleaned()
     jhu_data_df = JHUData.from_dataframe(df)
     assert isinstance(jhu_data_df, JHUData)
     jhu_data_df.records("Japan")