refactoring
This commit is contained in:
@@ -6,11 +6,11 @@ class SymptomsByBatchcodesTableFactory:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def createSymptomsByBatchcodesTable(VAERSVAX, VAERSSYMPTOMS):
|
def createSymptomsByBatchcodesTable(VAERSVAX, VAERSSYMPTOMS):
|
||||||
index_columns = SymptomsByBatchcodesTableFactory._getIndexColumns(VAERSVAX)
|
index_columns = SymptomsByBatchcodesTableFactory._getIndexColumns(VAERSVAX)
|
||||||
symptomsColumn = 'SYMPTOMS'
|
symptomColumn = 'SYMPTOM'
|
||||||
return pd.merge(
|
return pd.merge(
|
||||||
SymptomsByBatchcodesTableFactory._get_VAERSVAX_WITH_VAX_LOTS(VAERSVAX, index_columns),
|
SymptomsByBatchcodesTableFactory._get_VAERSVAX_WITH_VAX_LOTS(VAERSVAX, index_columns),
|
||||||
SymptomsByBatchcodesTableFactory._getSymptomsTable(VAERSSYMPTOMS, symptomsColumn),
|
SymptomsByBatchcodesTableFactory._getSymptomsTable(VAERSSYMPTOMS, symptomColumn),
|
||||||
on = 'VAERS_ID').set_index(index_columns)[[symptomsColumn]]
|
on = 'VAERS_ID').set_index(index_columns)[[symptomColumn]]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getIndexColumns(VAERSVAX):
|
def _getIndexColumns(VAERSVAX):
|
||||||
@@ -41,7 +41,7 @@ class SymptomsByBatchcodesTableFactory:
|
|||||||
index = VAX_LOT_LIST_Table.index)
|
index = VAX_LOT_LIST_Table.index)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _getSymptomsTable(VAERSSYMPTOMS, symptomsColumn):
|
def _getSymptomsTable(VAERSSYMPTOMS, symptomColumn):
|
||||||
return pd.concat(
|
return pd.concat(
|
||||||
[
|
[
|
||||||
VAERSSYMPTOMS['SYMPTOM1'],
|
VAERSSYMPTOMS['SYMPTOM1'],
|
||||||
@@ -49,7 +49,7 @@ class SymptomsByBatchcodesTableFactory:
|
|||||||
VAERSSYMPTOMS['SYMPTOM3'],
|
VAERSSYMPTOMS['SYMPTOM3'],
|
||||||
VAERSSYMPTOMS['SYMPTOM4'],
|
VAERSSYMPTOMS['SYMPTOM4'],
|
||||||
VAERSSYMPTOMS['SYMPTOM5']
|
VAERSSYMPTOMS['SYMPTOM5']
|
||||||
]).dropna().to_frame(name = symptomsColumn).reset_index()
|
]).dropna().to_frame(name = symptomColumn).reset_index()
|
||||||
|
|
||||||
def fillLsts(lsts, desiredLen, fillValue):
|
def fillLsts(lsts, desiredLen, fillValue):
|
||||||
return [fillLst(lst, desiredLen, fillValue) for lst in lsts]
|
return [fillLst(lst, desiredLen, fillValue) for lst in lsts]
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
|
|||||||
assert_frame_equal(
|
assert_frame_equal(
|
||||||
symptomsByBatchcodesTable,
|
symptomsByBatchcodesTable,
|
||||||
TestHelper.createDataFrame(
|
TestHelper.createDataFrame(
|
||||||
columns = ['SYMPTOMS'],
|
columns = ['SYMPTOM'],
|
||||||
data = [ ['Blood pressure orthostatic abnormal'],
|
data = [ ['Blood pressure orthostatic abnormal'],
|
||||||
['Head injury'],
|
['Head injury'],
|
||||||
['SARS-CoV-2 test positive'],
|
['SARS-CoV-2 test positive'],
|
||||||
@@ -90,7 +90,7 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
|
|||||||
assert_frame_equal(
|
assert_frame_equal(
|
||||||
symptomsByBatchcodesTable,
|
symptomsByBatchcodesTable,
|
||||||
TestHelper.createDataFrame(
|
TestHelper.createDataFrame(
|
||||||
columns = ['SYMPTOMS'],
|
columns = ['SYMPTOM'],
|
||||||
data = [ ['Blood pressure orthostatic abnormal'],
|
data = [ ['Blood pressure orthostatic abnormal'],
|
||||||
['Blood pressure orthostatic abnormal']],
|
['Blood pressure orthostatic abnormal']],
|
||||||
index = pd.Index(
|
index = pd.Index(
|
||||||
@@ -140,7 +140,7 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
|
|||||||
assert_frame_equal(
|
assert_frame_equal(
|
||||||
symptomsByBatchcodesTable,
|
symptomsByBatchcodesTable,
|
||||||
TestHelper.createDataFrame(
|
TestHelper.createDataFrame(
|
||||||
columns = ['SYMPTOMS'],
|
columns = ['SYMPTOM'],
|
||||||
data = [ ['Blood pressure orthostatic abnormal'],
|
data = [ ['Blood pressure orthostatic abnormal'],
|
||||||
['Head injury'],
|
['Head injury'],
|
||||||
['SARS-CoV-2 test positive'],
|
['SARS-CoV-2 test positive'],
|
||||||
|
|||||||
Reference in New Issue
Block a user