refactoring

This commit is contained in:
frankknoll
2022-11-22 15:51:53 +01:00
parent 8d1f38dfb6
commit 447c2ed552
5 changed files with 60 additions and 95 deletions

View File

@@ -1,15 +1,38 @@
from IOUtils import IOUtils
from BatchCodeTableFactory import BatchCodeTableFactory
import numpy as np
from HtmlUtils import getCountries
def createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality = None):
def createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality):
batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19)
_createAndSaveBatchCodeTablesForCountries(
createBatchCodeTableForCountry=lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(
country),
countries=getCountries(internationalVaersCovid19),
minADRsForLethality=minADRsForLethality)
_createAndSaveBatchCodeTableForCountry(
createBatchCodeTableForCountry=lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
country='Global',
minADRsForLethality=minADRsForLethality)
def _createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality=None):
batchCodeTable = createBatchCodeTableForCountry(country)
batchCodeTable.index.set_names("Batch", inplace = True)
batchCodeTable.index.set_names("Batch", inplace=True)
if minADRsForLethality is not None:
batchCodeTable.loc[batchCodeTable['Adverse Reaction Reports'] < minADRsForLethality, ['Severe reports', 'Lethality']] = [np.nan, np.nan]
IOUtils.saveDataFrame(batchCodeTable, '../docs/data/batchCodeTables/' + country)
batchCodeTable.loc[
batchCodeTable['Adverse Reaction Reports'] < minADRsForLethality,
['Severe reports', 'Lethality']
] = [np.nan, np.nan]
IOUtils.saveDataFrame(
batchCodeTable,
'../docs/data/batchCodeTables/' + country)
# display(country + ":", batchCodeTable)
display(country)
def createAndSaveBatchCodeTablesForCountries(createBatchCodeTableForCountry, countries, minADRsForLethality = None):
def _createAndSaveBatchCodeTablesForCountries(createBatchCodeTableForCountry, countries, minADRsForLethality=None):
for country in countries:
createAndSaveBatchCodeTableForCountry(createBatchCodeTableForCountry, country, minADRsForLethality)
_createAndSaveBatchCodeTableForCountry(
createBatchCodeTableForCountry, country, minADRsForLethality)