From e7256697c35ac5812833c8105f5d55d62acb0a9c Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sat, 1 Apr 2023 11:39:36 +0200 Subject: [PATCH] replacing 'Unknown Country' by None --- src/BatchCodeTableFactoryTest.py | 4 +-- src/CountryColumnAdderTest.py | 44 ++++++++++++++++---------------- src/HtmlUtils.py | 2 +- src/Splttype2CountryConverter.py | 2 +- src/SummationTableFactory.py | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/BatchCodeTableFactoryTest.py b/src/BatchCodeTableFactoryTest.py index 0f89c76dd12..758d9c328d4 100644 --- a/src/BatchCodeTableFactoryTest.py +++ b/src/BatchCodeTableFactoryTest.py @@ -86,7 +86,7 @@ class BatchCodeTableFactoryTest(unittest.TestCase): # Given dataFrame = TestHelper.createDataFrame( columns = ['DIED', 'L_THREAT', 'DISABLE', 'VAX_TYPE', 'VAX_MANU', 'VAX_LOT', 'VAX_DOSE_SERIES', 'SPLTTYPE', 'HOSPITAL', 'ER_VISIT', 'COUNTRY'], - data = [ [1, 0, 0, 'COVID19', 'PFIZER\BIONTECH', '016M20A', '2', 'GBPFIZER INC2020486806', 0, 0, 'United Kingdom'], + data = [ [1, 0, 0, 'COVID19', 'PFIZER\BIONTECH', '016M20A', '2', 'dummy', 0, 0, None], [0, 0, 0, 'COVID19', 'MODERNA', '030L20A', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'France'], [1, 1, 1, 'COVID19', 'MODERNA', '030L20B', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'France'], [0, 1, 1, 'COVID19', 'MODERNA', '030L20B', '1', 'FRMODERNATX, INC.MOD20224', 0, 0, 'United Kingdom']], @@ -106,7 +106,7 @@ class BatchCodeTableFactoryTest(unittest.TestCase): batchCodeTable[['Adverse Reaction Reports', 'Deaths', 'Disabilities', 'Life Threatening Illnesses', 'Company', 'Countries', 'Severe reports', 'Lethality']], TestHelper.createDataFrame( columns = ['Adverse Reaction Reports', 'Deaths', 'Disabilities', 'Life Threatening Illnesses', 'Company', 'Countries', 'Severe reports', 'Lethality'], - data = [ [1, 1, 0, 0, 'PFIZER\BIONTECH', self._convertCountries(['United Kingdom'], countriesAsList), 1/1 * 100, 1/1 * 100], + data = [ [1, 1, 0, 0, 'PFIZER\BIONTECH', self._convertCountries([], countriesAsList), 1/1 * 100, 1/1 * 100], [2, 1, 2, 2, 'MODERNA', self._convertCountries(['France', 'United Kingdom'], countriesAsList), 2/2 * 100, 1/2 * 100], [1, 0, 0, 0, 'MODERNA', self._convertCountries(['France'], countriesAsList), 0/1 * 100, 0/1 * 100]], index = pd.Index( diff --git a/src/CountryColumnAdderTest.py b/src/CountryColumnAdderTest.py index 0f18e4c6a30..43c966652b4 100644 --- a/src/CountryColumnAdderTest.py +++ b/src/CountryColumnAdderTest.py @@ -29,17 +29,17 @@ class CountryColumnAdderTest(unittest.TestCase): assert_frame_equal( dataFrameWithCountryColumn, TestHelper.createDataFrame( - columns = ['SPLTTYPE', 'COUNTRY'], - data = [ ['GBPFIZER INC2020486806', 'United Kingdom'], - ['FRMODERNATX, INC.MOD20224', 'France'], - ['dummy', 'Unknown Country']], - index = pd.Index( - name = 'VAERS_ID', - data = [ - "4711", - "0815", - "123"]), - dtypes = {'COUNTRY': 'string'})) + columns = ['SPLTTYPE', 'COUNTRY'], + data = [ ['GBPFIZER INC2020486806', 'United Kingdom'], + ['FRMODERNATX, INC.MOD20224', 'France'], + ['dummy', None]], + index = pd.Index( + name = 'VAERS_ID', + data = [ + "4711", + "0815", + "123"]), + dtypes = {'COUNTRY': 'string'})) def test_addCountryColumn2(self): @@ -75,14 +75,14 @@ class CountryColumnAdderTest(unittest.TestCase): assert_frame_equal( dataFrameWithCountryColumn, TestHelper.createDataFrame( - columns = ['VAX_LOT', 'COUNTRY'], - data = [ ['1808982', 'France'], - ['EW0175', 'France'], - ['EW0176', 'United Kingdom']], - index = pd.Index( - name = 'VAERS_ID', - data = [ - 2547730, - 2547730, - 2547744]), - dtypes = {'COUNTRY': 'string'})) + columns = ['VAX_LOT', 'COUNTRY'], + data = [ ['1808982', 'France'], + ['EW0175', 'France'], + ['EW0176', 'United Kingdom']], + index = pd.Index( + name = 'VAERS_ID', + data = [ + 2547730, + 2547730, + 2547744]), + dtypes = {'COUNTRY': 'string'})) diff --git a/src/HtmlUtils.py b/src/HtmlUtils.py index eea1b38b96e..46bf5b1388d 100644 --- a/src/HtmlUtils.py +++ b/src/HtmlUtils.py @@ -1,5 +1,5 @@ def getCountries(internationalVaersCovid19): - return sorted(internationalVaersCovid19['COUNTRY'].unique()) + return sorted(internationalVaersCovid19['COUNTRY'].dropna().unique()) def getCountryOptions(countries): diff --git a/src/Splttype2CountryConverter.py b/src/Splttype2CountryConverter.py index 33bc336fb64..87ca37f9737 100644 --- a/src/Splttype2CountryConverter.py +++ b/src/Splttype2CountryConverter.py @@ -16,7 +16,7 @@ class Splttype2CountryConverter: lambda splttype: Splttype2CountryConverter._getCountryNameOfSplttypeOrDefault( splttype = splttype, - default = 'Unknown Country')) + default = None)) .astype("string")) @staticmethod diff --git a/src/SummationTableFactory.py b/src/SummationTableFactory.py index 9963ead0f10..9f266b501fb 100644 --- a/src/SummationTableFactory.py +++ b/src/SummationTableFactory.py @@ -28,4 +28,4 @@ class SummationTableFactory: @staticmethod def sortCountries(countries): - return sorted(set(countries)) \ No newline at end of file + return sorted(set(countries.dropna())) \ No newline at end of file