adding BatchCodeTableIntoHistogramDescriptionTableMerger

This commit is contained in:
frankknoll
2023-04-12 23:46:33 +02:00
parent ecf9bb996f
commit a715dc6cab
6 changed files with 132 additions and 15 deletions

View File

@@ -2,13 +2,23 @@ from HistogramFactory import createHistograms
from HistogramPersister import saveHistograms
from MultiIndexExploder import MultiIndexExploder
from HistogramDescriptionTableFactory import HistogramDescriptionTableFactory
from BatchCodeTableIntoHistogramDescriptionTableMerger import BatchCodeTableIntoHistogramDescriptionTableMerger
def createAndSaveGlobalHistograms(symptomByBatchcodeTable):
def createAndSaveGlobalHistograms(symptomByBatchcodeTable, batchCodeTable):
symptomByBatchcodeTable = symptomByBatchcodeTable.assign(COUNTRY = 'Global')
dictByBatchcodeTable = createHistograms(symptomByBatchcodeTable)
explodedTable = MultiIndexExploder.explodeMultiIndexOfTable(dictByBatchcodeTable)
histogramDescriptionTable = HistogramDescriptionTableFactory.createHistogramDescriptionTable(explodedTable)
histogramDescriptionTable = BatchCodeTableIntoHistogramDescriptionTableMerger.mergeBatchCodeTableIntoHistogramDescriptionTable(
batchCodeTable = _rearrange(batchCodeTable),
histogramDescriptionTable = histogramDescriptionTable)
for country, histogramDescriptionTableForCountry in histogramDescriptionTable.groupby('COUNTRY'):
print(f'saving histograms for {country}')
saveHistograms(histogramDescriptionTableForCountry, country)
saveHistograms(histogramDescriptionTableForCountry, country)
def _rearrange(batchCodeTable):
batchCodeTable = batchCodeTable.set_index('Batch')
batchCodeTable.index.rename('VAX_LOT', inplace = True)
return batchCodeTable