refactoring

This commit is contained in:
frankknoll
2023-04-03 21:45:12 +02:00
parent eab96f30f1
commit f74f007ffb
4 changed files with 15 additions and 38 deletions

View File

@@ -1,15 +0,0 @@
import pandas as pd
class ADRColumnAdder:
def __init__(self, ADR_by_Batchcode):
self.ADR_by_Batchcode = ADR_by_Batchcode
def addADRColumn(self, vaccineDistributionByZipcode):
return pd.merge(
vaccineDistributionByZipcode,
self.ADR_by_Batchcode,
how = 'left',
left_on = 'LOT_NUMBER',
right_index = True,
validate = 'many_to_one')

View File

@@ -0,0 +1,11 @@
import pandas as pd
def addColumn2Dataframe(dataframe, column):
return pd.merge(
dataframe,
column,
how = 'left',
left_on = 'LOT_NUMBER',
right_index = True,
validate = 'many_to_one')

View File

@@ -21,7 +21,8 @@
"from BatchCodeTablePersister import createAndSaveGlobalBatchCodeTable\n",
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n",
"from BatchCodeTableFactory import BatchCodeTableFactory"
"from BatchCodeTableFactory import BatchCodeTableFactory\n",
"from Column2DataframeAdder import addColumn2Dataframe"
]
},
{
@@ -208,9 +209,7 @@
"metadata": {},
"outputs": [],
"source": [
"from OVERALL_DOSES_SHIPPEDColumnAdder import OVERALL_DOSES_SHIPPEDColumnAdder\n",
"\n",
"vaccineDistributionByZipcode = OVERALL_DOSES_SHIPPEDColumnAdder(OVERALL_DOSES_SHIPPED_by_LOT_NUMBER).addColumn(vaccineDistributionByZipcode)\n",
"vaccineDistributionByZipcode = addColumn2Dataframe(dataframe = vaccineDistributionByZipcode, column = OVERALL_DOSES_SHIPPED_by_LOT_NUMBER)\n",
"vaccineDistributionByZipcode"
]
},
@@ -234,9 +233,7 @@
"metadata": {},
"outputs": [],
"source": [
"from ADRColumnAdder import ADRColumnAdder\n",
"\n",
"vaccineDistributionByZipcode = ADRColumnAdder(ADR_by_Batchcode_Table_4USA).addADRColumn(vaccineDistributionByZipcode)\n",
"vaccineDistributionByZipcode = addColumn2Dataframe(dataframe = vaccineDistributionByZipcode, column = ADR_by_Batchcode_Table_4USA)\n",
"vaccineDistributionByZipcode"
]
},

View File

@@ -1,16 +0,0 @@
import pandas as pd
# FK-TODO: DRY with ADRColumnAdder
class OVERALL_DOSES_SHIPPEDColumnAdder:
def __init__(self, OVERALL_DOSES_SHIPPED_by_LOT_NUMBER):
self.OVERALL_DOSES_SHIPPED_by_LOT_NUMBER = OVERALL_DOSES_SHIPPED_by_LOT_NUMBER
def addColumn(self, vaccineDistributionByZipcode):
return pd.merge(
vaccineDistributionByZipcode,
self.OVERALL_DOSES_SHIPPED_by_LOT_NUMBER,
how = 'left',
left_on = 'LOT_NUMBER',
right_index = True,
validate = 'many_to_one')