diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 16be1d25e6e..646607c7d8b 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -110,6 +110,16 @@ "symptomByBatchcodeTable" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "5997ee59", + "metadata": {}, + "outputs": [], + "source": [ + "isGlobal = True" + ] + }, { "cell_type": "code", "execution_count": null, @@ -119,7 +129,7 @@ "source": [ "from SymptomHistogramByBatchcodeTableFactory import SymptomHistogramByBatchcodeTableFactory\n", "\n", - "symptomHistogramByBatchcodeTable = SymptomHistogramByBatchcodeTableFactory.createSymptomHistogramByBatchcodeTable(symptomByBatchcodeTable)\n", + "symptomHistogramByBatchcodeTable = SymptomHistogramByBatchcodeTableFactory.createGlobalSymptomHistogramByBatchcodeTable(symptomByBatchcodeTable) if isGlobal else SymptomHistogramByBatchcodeTableFactory.createSymptomHistogramByBatchcodeTable(symptomByBatchcodeTable)\n", "symptomHistogramByBatchcodeTable" ] }, @@ -132,7 +142,7 @@ "source": [ "from HistogramTable2DictTableConverter import HistogramTable2DictTableConverter\n", "\n", - "dictByBatchcodeTable = HistogramTable2DictTableConverter.convertHistogramTable2DictTable(symptomHistogramByBatchcodeTable)\n", + "dictByBatchcodeTable = HistogramTable2DictTableConverter.convertGlobalHistogramTable2DictTable(symptomHistogramByBatchcodeTable) if isGlobal else HistogramTable2DictTableConverter.convertHistogramTable2DictTable(symptomHistogramByBatchcodeTable)\n", "dictByBatchcodeTable" ] }, @@ -148,21 +158,32 @@ "from HistogramDescriptionPersister import HistogramDescriptionPersister\n", "import shutil\n", "\n", - "countries = getCountries(international_VAERSVAX_Covid19)\n", - "\n", - "for count, country in enumerate(countries, start = 1):\n", - " # FK-TODO: use https://github.com/tqdm/tqdm\n", - " print(f'saving histograms for country {count}/{len(countries)}: {country}')\n", - " dictByBatchcodeTable4Country = dictByBatchcodeTable[dictByBatchcodeTable['COUNTRY'] == country]\n", - " batchcodes = MultiIndexValuesProvider.getValues(dictByBatchcodeTable4Country.index)\n", + "if isGlobal:\n", + " batchcodes = MultiIndexValuesProvider.getValues(dictByBatchcodeTable.index)\n", " batchcodes = {batchcode for batchcode in batchcodes if batchcode != 'nan'}\n", - " directory = f'../docs/data/histograms/{country}'\n", + " # directory = f'../docs/data/histograms/global'\n", + " directory = f'../docs/data/histograms'\n", " shutil.rmtree(directory, ignore_errors = True)\n", " histogramDescriptionPersister = HistogramDescriptionPersister(directory)\n", " histogramDescriptionPersister.saveHistogramDescriptionsForBatchcodes(\n", " batchcodes,\n", - " dictByBatchcodeTable4Country,\n", - " progress = lambda count, size, batchcode: print(f'{count}/{size}: {batchcode}'))" + " dictByBatchcodeTable,\n", + " progress = lambda count, size, batchcode: print(f'{count}/{size}: {batchcode}'))\n", + "else:\n", + " countries = getCountries(international_VAERSVAX_Covid19)\n", + " for count, country in enumerate(countries, start = 1):\n", + " # FK-TODO: use https://github.com/tqdm/tqdm\n", + " print(f'saving histograms for country {count}/{len(countries)}: {country}')\n", + " dictByBatchcodeTable4Country = dictByBatchcodeTable[dictByBatchcodeTable['COUNTRY'] == country]\n", + " batchcodes = MultiIndexValuesProvider.getValues(dictByBatchcodeTable4Country.index)\n", + " batchcodes = {batchcode for batchcode in batchcodes if batchcode != 'nan'}\n", + " directory = f'../docs/data/histograms/{country}'\n", + " shutil.rmtree(directory, ignore_errors = True)\n", + " histogramDescriptionPersister = HistogramDescriptionPersister(directory)\n", + " histogramDescriptionPersister.saveHistogramDescriptionsForBatchcodes(\n", + " batchcodes,\n", + " dictByBatchcodeTable4Country,\n", + " progress = lambda count, size, batchcode: print(f'{count}/{size}: {batchcode}'))" ] }, { @@ -213,9 +234,9 @@ ], "metadata": { "kernelspec": { - "display_name": "howbadismybatch-venv-kernel", + "display_name": "howbadismybatch-venv", "language": "python", - "name": "howbadismybatch-venv-kernel" + "name": "python3" }, "language_info": { "codemirror_mode": {