refactoring
This commit is contained in:
@@ -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')
|
|
||||||
11
src/Column2DataframeAdder.py
Normal file
11
src/Column2DataframeAdder.py
Normal 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')
|
||||||
@@ -21,7 +21,8 @@
|
|||||||
"from BatchCodeTablePersister import createAndSaveGlobalBatchCodeTable\n",
|
"from BatchCodeTablePersister import createAndSaveGlobalBatchCodeTable\n",
|
||||||
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
|
"from SymptomByBatchcodeTableFactory import SymptomByBatchcodeTableFactory\n",
|
||||||
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n",
|
"from HistogramFactoryAndPersister import createAndSaveGlobalHistograms\n",
|
||||||
"from BatchCodeTableFactory import BatchCodeTableFactory"
|
"from BatchCodeTableFactory import BatchCodeTableFactory\n",
|
||||||
|
"from Column2DataframeAdder import addColumn2Dataframe"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -208,9 +209,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from OVERALL_DOSES_SHIPPEDColumnAdder import OVERALL_DOSES_SHIPPEDColumnAdder\n",
|
"vaccineDistributionByZipcode = addColumn2Dataframe(dataframe = vaccineDistributionByZipcode, column = OVERALL_DOSES_SHIPPED_by_LOT_NUMBER)\n",
|
||||||
"\n",
|
|
||||||
"vaccineDistributionByZipcode = OVERALL_DOSES_SHIPPEDColumnAdder(OVERALL_DOSES_SHIPPED_by_LOT_NUMBER).addColumn(vaccineDistributionByZipcode)\n",
|
|
||||||
"vaccineDistributionByZipcode"
|
"vaccineDistributionByZipcode"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -234,9 +233,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from ADRColumnAdder import ADRColumnAdder\n",
|
"vaccineDistributionByZipcode = addColumn2Dataframe(dataframe = vaccineDistributionByZipcode, column = ADR_by_Batchcode_Table_4USA)\n",
|
||||||
"\n",
|
|
||||||
"vaccineDistributionByZipcode = ADRColumnAdder(ADR_by_Batchcode_Table_4USA).addADRColumn(vaccineDistributionByZipcode)\n",
|
|
||||||
"vaccineDistributionByZipcode"
|
"vaccineDistributionByZipcode"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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')
|
|
||||||
Reference in New Issue
Block a user