generating histograms for countries more efficient

This commit is contained in:
frankknoll
2023-02-16 14:59:43 +01:00
parent ef7c36d567
commit 0ffc5881b6
8 changed files with 139 additions and 136 deletions

View File

@@ -13,18 +13,8 @@ def createAndSaveGlobalHistograms(symptomByBatchcodeTable):
def createAndSaveHistogramsForCountries(symptomByBatchcodeTable, countries):
dictByBatchcodeTable = createHistograms(symptomByBatchcodeTable)
for count, country in enumerate(countries, start = 1):
_createAndSaveHistogramsForCountry(
count = count,
numCountries = len(countries),
country = country,
dictByBatchcodeTable = dictByBatchcodeTable)
def _createAndSaveHistogramsForCountry(count, numCountries, country, dictByBatchcodeTable):
# FK-TODO: use https://github.com/tqdm/tqdm
print(f'saving histograms for country {count}/{numCountries}: {country}')
dictByBatchcodeTable4Country = dictByBatchcodeTable[dictByBatchcodeTable['COUNTRY'] == country]
explodedTable = MultiIndexExploder.explodeMultiIndexOfTable(dictByBatchcodeTable4Country)
explodedTable = MultiIndexExploder.explodeMultiIndexOfTable(dictByBatchcodeTable)
histogramDescriptionTable = HistogramDescriptionTableFactory.createHistogramDescriptionTable(explodedTable)
saveHistograms(histogramDescriptionTable, country)
for country, histogramDescriptionTableForCountry in histogramDescriptionTable.groupby('COUNTRY'):
print(country, ':')
saveHistograms(histogramDescriptionTableForCountry, country)