making SymptomsByBatchcodesTableFactoryTest pass
This commit is contained in:
@@ -4,5 +4,33 @@ import pandas as pd
|
|||||||
class SymptomsByBatchcodesTableFactory:
|
class SymptomsByBatchcodesTableFactory:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def createSymptomsByBatchcodesTable(vaxTable, symptomsTable):
|
def createSymptomsByBatchcodesTable(VAERSVAX, VAERSSYMPTOMS):
|
||||||
return pd.DataFrame({'A': []})
|
return pd.merge(
|
||||||
|
SymptomsByBatchcodesTableFactory._get_VAERSVAX_WITH_VAX_LOTS(VAERSVAX),
|
||||||
|
SymptomsByBatchcodesTableFactory._getSymptomsTable(VAERSSYMPTOMS),
|
||||||
|
on = 'VAERS_ID').set_index(['VAX_LOT1', 'VAX_LOT2'])[['SYMPTOMS']]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_VAERSVAX_WITH_VAX_LOTS(VAERSVAX):
|
||||||
|
return pd.concat(
|
||||||
|
[VAERSVAX, SymptomsByBatchcodesTableFactory._getVaxLotsTable(VAERSVAX)],
|
||||||
|
axis=1).drop_duplicates(subset=['VAX_LOT1', 'VAX_LOT2']).reset_index()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _getVaxLotsTable(VAERSVAX):
|
||||||
|
VAX_LOT_LIST_Table = VAERSVAX.groupby("VAERS_ID").agg(VAX_LOT_LIST = pd.NamedAgg(column = 'VAX_LOT', aggfunc = list))
|
||||||
|
return pd.DataFrame(
|
||||||
|
VAX_LOT_LIST_Table['VAX_LOT_LIST'].tolist(),
|
||||||
|
columns = ['VAX_LOT1', 'VAX_LOT2'],
|
||||||
|
index = VAX_LOT_LIST_Table.index)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _getSymptomsTable(VAERSSYMPTOMS):
|
||||||
|
return pd.concat(
|
||||||
|
[
|
||||||
|
VAERSSYMPTOMS['SYMPTOM1'],
|
||||||
|
VAERSSYMPTOMS['SYMPTOM2'],
|
||||||
|
VAERSSYMPTOMS['SYMPTOM3'],
|
||||||
|
VAERSSYMPTOMS['SYMPTOM4'],
|
||||||
|
VAERSSYMPTOMS['SYMPTOM5']
|
||||||
|
]).dropna().drop_duplicates().to_frame(name = "SYMPTOMS").reset_index()
|
||||||
|
|||||||
@@ -40,8 +40,20 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
|
|||||||
assert_frame_equal(
|
assert_frame_equal(
|
||||||
symptomsByBatchcodesTable,
|
symptomsByBatchcodesTable,
|
||||||
TestHelper.createDataFrame(
|
TestHelper.createDataFrame(
|
||||||
columns = ['Blood pressure orthostatic abnormal', 'COVID-19', 'Coma', 'Computerised tomogram', 'Exposure to SARS-CoV-2', 'Head injury', 'Headache', 'Laboratory test', 'Magnetic resonance imaging', 'SARS-CoV-2 antibody test negative', 'SARS-CoV-2 test positive', 'Unresponsive to stimuli', 'X-ray'],
|
columns = ['SYMPTOMS'],
|
||||||
data = [ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
|
data = [ ['Blood pressure orthostatic abnormal'],
|
||||||
|
['Head injury'],
|
||||||
|
['SARS-CoV-2 test positive'],
|
||||||
|
['COVID-19'],
|
||||||
|
['Headache'],
|
||||||
|
['Unresponsive to stimuli'],
|
||||||
|
['Coma'],
|
||||||
|
['Laboratory test'],
|
||||||
|
['X-ray'],
|
||||||
|
['Computerised tomogram'],
|
||||||
|
['Magnetic resonance imaging'],
|
||||||
|
['Exposure to SARS-CoV-2'],
|
||||||
|
['SARS-CoV-2 antibody test negative']],
|
||||||
index = pd.MultiIndex.from_tuples(
|
index = pd.MultiIndex.from_tuples(
|
||||||
names = ['VAX_LOT1', 'VAX_LOT2'],
|
names = ['VAX_LOT1', 'VAX_LOT2'],
|
||||||
tuples = [['1808982', 'EW0175']])))
|
tuples = [['1808982', 'EW0175']] * 13)))
|
||||||
|
|||||||
Reference in New Issue
Block a user