sorting VAX_LOTs

This commit is contained in:
frankknoll
2023-01-22 21:49:14 +01:00
parent 5dbd3d310a
commit 2ddf57631d
2 changed files with 8 additions and 5 deletions

View File

@@ -28,7 +28,10 @@ class SymptomsByBatchcodesTableFactory:
@staticmethod
def _getVaxLotsTable(VAERSVAX, index_columns):
VAX_LOT_LIST_Table = VAERSVAX.groupby("VAERS_ID").agg(VAX_LOT_LIST = pd.NamedAgg(column = 'VAX_LOT', aggfunc = list))
VAX_LOT_LIST_Table = VAERSVAX.groupby("VAERS_ID").agg(
VAX_LOT_LIST = pd.NamedAgg(
column = 'VAX_LOT',
aggfunc = lambda x: sorted(list(x))))
return pd.DataFrame(
fillLsts(
lsts = VAX_LOT_LIST_Table['VAX_LOT_LIST'].tolist(),

View File

@@ -11,8 +11,8 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
# Given
VAERSVAX = TestHelper.createDataFrame(
columns = ['VAX_TYPE', 'VAX_MANU', 'VAX_LOT', 'VAX_DOSE_SERIES'],
data = [ ['COVID19', 'JANSSEN', '1808982', 'UNK'],
['COVID19', 'PFIZER\BIONTECH', 'EW0175', '1']],
data = [ ['COVID19', 'JANSSEN', 'EW0175', 'UNK'],
['COVID19', 'PFIZER\BIONTECH', '1808982', '1']],
index = pd.Index(
name = 'VAERS_ID',
data=[
@@ -56,7 +56,7 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
['SARS-CoV-2 antibody test negative']],
index = pd.MultiIndex.from_tuples(
names = ['VAX_LOT1', 'VAX_LOT2'],
tuples = [['1808982', 'EW0175']] * 13)))
tuples = [['1808982', 'EW0175']] * 13)))
def test_createSymptomsByBatchcodesTable_two_patients_same_symptoms(self):
# Given
@@ -166,6 +166,6 @@ class SymptomsByBatchcodesTableFactoryTest(unittest.TestCase):
['Vision blurred']],
index = pd.MultiIndex.from_tuples(
names = ['VAX_LOT1', 'VAX_LOT2'],
tuples = [['1808982', 'EW0175']] * 13 + [['EW0175', 'EW0167']] * 10)))
tuples = [['1808982', 'EW0175']] * 13 + [['EW0167', 'EW0175']] * 10)))