refactoring
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user