generating histograms for all countries

This commit is contained in:
frankknoll
2023-02-10 08:47:06 +01:00
parent 4bc82d992b
commit 41524ed839

View File

@@ -107,21 +107,9 @@
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n", "from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
"\n", "\n",
"symptomByBatchcodeTable = SymptomByBatchcodeTableFactory.createSymptomByBatchcodeTable(international_VAERSVAX_Covid19, international_VAERSSYMPTOMS)\n", "symptomByBatchcodeTable = SymptomByBatchcodeTableFactory.createSymptomByBatchcodeTable(international_VAERSVAX_Covid19, international_VAERSSYMPTOMS)\n",
"# symptomByBatchcodeTable.to_pickle('tmp/symptomByBatchcodeTable.pkl')\n",
"symptomByBatchcodeTable" "symptomByBatchcodeTable"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "b5a70fa0",
"metadata": {},
"outputs": [],
"source": [
"# symptomByBatchcodeTable = pd.read_pickle('tmp/symptomByBatchcodeTable.pkl')\n",
"# symptomByBatchcodeTable"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -151,31 +139,41 @@
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "5e2a0a30", "id": "a57e0fd5",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"batchcodes = international_VAERSVAX_Covid19['VAX_LOT'].dropna().drop_duplicates().to_list()\n", "from HtmlUtils import getCountries\n",
"batchcodes" "from MultiIndexValuesProvider import MultiIndexValuesProvider\n",
"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",
" 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}'))"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"id": "6e6efc19", "id": "5e2a0a30",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from HistogramDescriptionPersister import HistogramDescriptionPersister\n", "# batchcodes = international_VAERSVAX_Covid19['VAX_LOT'].dropna().drop_duplicates().to_list()\n",
"import shutil\n", "# batchcodes"
"\n",
"directory = '../docs/data/histograms'\n",
"shutil.rmtree(directory)\n",
"histogramDescriptionPersister = HistogramDescriptionPersister(directory)\n",
"histogramDescriptionPersister.saveHistogramDescriptionsForBatchcodes(\n",
" batchcodes,\n",
" dictByBatchcodeTable,\n",
" progress = lambda count, size, batchcode: print(f'{count}/{size}: {batchcode}'))"
] ]
}, },
{ {
@@ -215,9 +213,9 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "howbadismybatch-venv", "display_name": "howbadismybatch-venv-kernel",
"language": "python", "language": "python",
"name": "python3" "name": "howbadismybatch-venv-kernel"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": {