adding function getCountriesByClickedBatchcode()

This commit is contained in:
frankknoll
2023-05-30 00:03:44 +02:00
parent 6d65921abc
commit cd4b21eda4
2 changed files with 13 additions and 0 deletions

View File

@@ -21,5 +21,6 @@ class BatchCodeTableHavingGuessedCountriesFactory:
def _guessCountries(self, batchCodeTable, countriesAsList): def _guessCountries(self, batchCodeTable, countriesAsList):
batchCodeTable['Countries'] = CountriesMerger.mergeSrcIntoDst( batchCodeTable['Countries'] = CountriesMerger.mergeSrcIntoDst(
dst = batchCodeTable['Countries'], dst = batchCodeTable['Countries'],
# FK-TODO: zusätzlich zu self.countriesByBatchcodeBeforeDeletion auch noch mit dem Ergebnis der noch zu implementierenden Funktion CountriesByBatchcodeProvider.getCountriesByClickedBatchcode() mergen.
src = self.countriesByBatchcodeBeforeDeletion['Countries']) src = self.countriesByBatchcodeBeforeDeletion['Countries'])
BatchCodeTableFactory._convertCountries(batchCodeTable, countriesAsList) BatchCodeTableFactory._convertCountries(batchCodeTable, countriesAsList)

View File

@@ -1,6 +1,7 @@
import pandas as pd import pandas as pd
from BatchCodeTableFactory import BatchCodeTableFactory from BatchCodeTableFactory import BatchCodeTableFactory
from InternationalVaersCovid19Provider import getInternationalVaersCovid19 from InternationalVaersCovid19Provider import getInternationalVaersCovid19
from SummationTableFactory import SummationTableFactory
def getCountryCountsByBatchcodeTable(): def getCountryCountsByBatchcodeTable():
@@ -45,6 +46,17 @@ def _combineCountryCountsByBatchcodeTables(countryCountsByClickedBatchcode, coun
return countryCountsByBatchcode return countryCountsByBatchcode
def getCountriesByClickedBatchcode():
return (_getCountryCountsByClickedBatchcode()
.reset_index(level = 'COUNTRY')
.groupby('VAX_LOT')
.agg(
Countries =
pd.NamedAgg(
column = 'COUNTRY',
aggfunc = SummationTableFactory.sortCountries)))
def getCountriesByBatchcodeBeforeDeletion(): def getCountriesByBatchcodeBeforeDeletion():
internationalVaersCovid19 = getInternationalVaersCovid19(dataDir = 'VAERS/VAERSBeforeDeletion', years = [2020, 2021, 2022]) internationalVaersCovid19 = getInternationalVaersCovid19(dataDir = 'VAERS/VAERSBeforeDeletion', years = [2020, 2021, 2022])
batchCodeTable = BatchCodeTableFactory(internationalVaersCovid19).createGlobalBatchCodeTable(countriesAsList = True) batchCodeTable = BatchCodeTableFactory(internationalVaersCovid19).createGlobalBatchCodeTable(countriesAsList = True)