updating Countries column
This commit is contained in:
@@ -22,8 +22,7 @@ class BatchCodeTableFactory:
|
||||
|
||||
def _postProcess(self, batchCodeTable, countriesAsList):
|
||||
batchCodeTable = self.companyColumnAdder.addCompanyColumn(batchCodeTable)
|
||||
if not countriesAsList:
|
||||
batchCodeTable['Countries'] = batchCodeTable['Countries'].apply(', '.join)
|
||||
BatchCodeTableFactory._convertCountries(batchCodeTable, countriesAsList)
|
||||
batchCodeTable = batchCodeTable[
|
||||
[
|
||||
'Adverse Reaction Reports',
|
||||
@@ -37,6 +36,11 @@ class BatchCodeTableFactory:
|
||||
]]
|
||||
return batchCodeTable.sort_values(by = 'Severe reports', ascending = False)
|
||||
|
||||
@staticmethod
|
||||
def _convertCountries(batchCodeTable, countriesAsList):
|
||||
if not countriesAsList:
|
||||
batchCodeTable['Countries'] = batchCodeTable['Countries'].apply(', '.join)
|
||||
|
||||
def _getBatchCodeTableByCountry(self, country):
|
||||
if country in self.countryBatchCodeTable.index:
|
||||
return self.countryBatchCodeTable.loc[country]
|
||||
|
||||
25
src/BatchCodeTableHavingGuessedCountriesFactory.py
Normal file
25
src/BatchCodeTableHavingGuessedCountriesFactory.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from CountriesMerger import CountriesMerger
|
||||
from CountriesByBatchcodeProvider import getCountriesByBatchcodeBeforeDeletion
|
||||
from BatchCodeTableFactory import BatchCodeTableFactory
|
||||
|
||||
class BatchCodeTableHavingGuessedCountriesFactory:
|
||||
|
||||
def __init__(self, batchCodeTableFactoryDelegate):
|
||||
self.batchCodeTableFactoryDelegate = batchCodeTableFactoryDelegate
|
||||
self.countriesByBatchcodeBeforeDeletion = getCountriesByBatchcodeBeforeDeletion()
|
||||
|
||||
def createGlobalBatchCodeTable(self, countriesAsList = False):
|
||||
batchCodeTable = self.batchCodeTableFactoryDelegate.createGlobalBatchCodeTable(countriesAsList = True)
|
||||
self._guessCountries(batchCodeTable, countriesAsList)
|
||||
return batchCodeTable
|
||||
|
||||
def createBatchCodeTableByCountry(self, country, countriesAsList = False):
|
||||
batchCodeTable = self.batchCodeTableFactoryDelegate.createBatchCodeTableByCountry(country, countriesAsList = True)
|
||||
self._guessCountries(batchCodeTable, countriesAsList)
|
||||
return batchCodeTable
|
||||
|
||||
def _guessCountries(self, batchCodeTable, countriesAsList):
|
||||
batchCodeTable['Countries'] = CountriesMerger.mergeSrcIntoDst(
|
||||
dst = batchCodeTable['Countries'],
|
||||
src = self.countriesByBatchcodeBeforeDeletion['Countries'])
|
||||
BatchCodeTableFactory._convertCountries(batchCodeTable, countriesAsList)
|
||||
@@ -1,5 +1,4 @@
|
||||
from IOUtils import IOUtils
|
||||
from BatchCodeTableFactory import BatchCodeTableFactory
|
||||
import numpy as np
|
||||
from HtmlUtils import getCountries
|
||||
|
||||
@@ -7,15 +6,14 @@ from HtmlUtils import getCountries
|
||||
def createAndSaveBatchCodeTables(
|
||||
internationalVaersCovid19,
|
||||
minADRsForLethality,
|
||||
batchCodeTableFactory,
|
||||
onCountryProcessed = lambda country: None):
|
||||
batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19)
|
||||
_createAndSaveBatchCodeTablesForCountries(
|
||||
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(country),
|
||||
countries = getCountries(internationalVaersCovid19),
|
||||
minADRsForLethality = minADRsForLethality,
|
||||
onCountryProcessed = onCountryProcessed)
|
||||
_createAndSaveBatchCodeTableForCountry(
|
||||
# FK-TODO: createBatchCodeTableForCountry so definieren, dass createGlobalBatchCodeTable() sofort die gemergten Countries erzeugt
|
||||
createBatchCodeTableForCountry = lambda country: batchCodeTableFactory.createGlobalBatchCodeTable(),
|
||||
country = 'Global',
|
||||
minADRsForLethality = minADRsForLethality,
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile\n",
|
||||
"from BatchCodeTablePersister import createAndSaveBatchCodeTables\n",
|
||||
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
|
||||
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms, createAndSaveHistogramsForCountries"
|
||||
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms, createAndSaveHistogramsForCountries\n",
|
||||
"from BatchCodeTableFactory import BatchCodeTableFactory\n",
|
||||
"from BatchCodeTableHavingGuessedCountriesFactory import BatchCodeTableHavingGuessedCountriesFactory\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -141,134 +143,6 @@
|
||||
"internationalVaersCovid19"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4e789358",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from CountriesByBatchcodeProvider import getCountriesByBatchcodeBeforeDeletion\n",
|
||||
"\n",
|
||||
"countriesByBatchcodeBeforeDeletion = getCountriesByBatchcodeBeforeDeletion()\n",
|
||||
"countriesByBatchcodeBeforeDeletion"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "15ec979e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"countriesByBatchcodeBeforeDeletion.to_csv('tmp/countriesByBatchcodeBeforeDeletion.csv')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0e7dae70",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from CountriesByBatchcodeProvider import getCountriesByCompletedBatchcode\n",
|
||||
"\n",
|
||||
"countriesByCompletedBatchcode = getCountriesByCompletedBatchcode(internationalVaersCovid19)\n",
|
||||
"countriesByCompletedBatchcode"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0087d657",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from CountriesByBatchcodeProvider import getCountriesByClickedBatchcode\n",
|
||||
"\n",
|
||||
"countriesByClickedBatchcode = getCountriesByClickedBatchcode()\n",
|
||||
"countriesByClickedBatchcode"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d6dd7355",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from BatchCodeTableFactory import BatchCodeTableFactory\n",
|
||||
"\n",
|
||||
"batchCodeTable = BatchCodeTableFactory(internationalVaersCovid19).createGlobalBatchCodeTable(countriesAsList = True)\n",
|
||||
"batchCodeTable"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "96d4a25c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"batchCodeTable['Countries']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "cefbcdc3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"countriesByBatchcodeBeforeDeletion['Countries']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d9b2bc07",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from CountriesMerger import CountriesMerger\n",
|
||||
"\n",
|
||||
"mergedCountries = CountriesMerger.mergeSrcIntoDst(dst = batchCodeTable['Countries'], src = countriesByBatchcodeBeforeDeletion['Countries'])\n",
|
||||
"mergedCountries"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "6ae58448",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"batchCodeTable['Countries'] = mergedCountries\n",
|
||||
"batchCodeTable"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "12593012",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mergedCountries.to_excel('tmp/mergedCountries.xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "40321fd4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"country_By_Batchcode_Search_Term.to_excel('tmp/Country_By_Batchcode_Search_Term.xlsx')\n",
|
||||
"FK-TODO: country_By_Batchcode_Search_Term['Completed Batchcode'] + Country-Spalten dazu verwenden,\n",
|
||||
" in der BatchCodeTable der Web-Seite fehlende mit 'Unknown Country' markierte Countries nachzutragen."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -289,6 +163,7 @@
|
||||
"createAndSaveBatchCodeTables(\n",
|
||||
" internationalVaersCovid19,\n",
|
||||
" minADRsForLethality = 100,\n",
|
||||
" batchCodeTableFactory = BatchCodeTableHavingGuessedCountriesFactory(BatchCodeTableFactory(internationalVaersCovid19)),\n",
|
||||
" onCountryProcessed = display)"
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user