saveBatchCodeTable()
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ VAERS/
|
|||||||
.ipynb_checkpoints/
|
.ipynb_checkpoints/
|
||||||
VAERSDataUseGuide_en_September2021.pdf
|
VAERSDataUseGuide_en_September2021.pdf
|
||||||
Vaccine Lot Numbers Expiration (1).xlsx
|
Vaccine Lot Numbers Expiration (1).xlsx
|
||||||
|
results/
|
||||||
|
|||||||
@@ -44,17 +44,17 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def createPivotTable(df):\n",
|
"def createBatchCodeTable(df):\n",
|
||||||
" def filter(df, col):\n",
|
" def filter(df, col):\n",
|
||||||
" return df[df[col] == 'Y'][['VAX_LOT']]\n",
|
" return df[df[col] == 'Y'][['VAX_LOT']]\n",
|
||||||
"\n",
|
"\n",
|
||||||
" pivotTableDict = {\n",
|
" batchCodeTableDict = {\n",
|
||||||
" 'ADRs': df[['VAX_LOT']].value_counts(),\n",
|
" 'ADRs': df[['VAX_LOT']].value_counts(),\n",
|
||||||
" 'DEATHS': filter(df, 'DIED').value_counts(),\n",
|
" 'DEATHS': filter(df, 'DIED').value_counts(),\n",
|
||||||
" 'DISABILITIES': filter(df, 'DISABLE').value_counts(),\n",
|
" 'DISABILITIES': filter(df, 'DISABLE').value_counts(),\n",
|
||||||
" 'LIFE THREATENING ILLNESSES': filter(df, 'L_THREAT').value_counts()\n",
|
" 'LIFE THREATENING ILLNESSES': filter(df, 'L_THREAT').value_counts()\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
" return pd.concat(pivotTableDict, axis=1).replace(to_replace=np.nan, value=0)\n"
|
" return pd.concat(batchCodeTableDict, axis=1).replace(to_replace=np.nan, value=0)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"df_moderna = createDataFrame(\"VAERS\", \"MODERNA\")"
|
"def saveBatchCodeTable(manufacturer, excelFile):\n",
|
||||||
|
" createBatchCodeTable(createDataFrame(\"VAERS\", manufacturer)).to_excel(excelFile)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -74,29 +75,9 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"df_moderna"
|
"saveBatchCodeTable(\"MODERNA\", \"results/moderna.xlsx\")\n",
|
||||||
]
|
"saveBatchCodeTable(\"PFIZER\\BIONTECH\", \"results/pfizer.xlsx\")\n",
|
||||||
},
|
"saveBatchCodeTable(\"JANSSEN\", \"results/janssen.xlsx\")"
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "d9191d12",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"pivotTable = createPivotTable(df_moderna)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "bb7b2963",
|
|
||||||
"metadata": {
|
|
||||||
"scrolled": false
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"pivotTable"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -121,12 +102,14 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"class HowBadIsMyBatchTest(unittest.TestCase):\n",
|
"class HowBadIsMyBatchTest(unittest.TestCase):\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def test_createPivotTable(self):\n",
|
" def test_createBatchCodeTable(self):\n",
|
||||||
" # Given\n",
|
" # Given\n",
|
||||||
" pivotTable = createPivotTable(createDataFrame(\"test/VAERS\", \"MODERNA\"))\n",
|
" dataFrame = createDataFrame(\"test/VAERS\", \"MODERNA\")\n",
|
||||||
|
" display(\"dataFrame:\", dataFrame)\n",
|
||||||
|
" batchCodeTable = createBatchCodeTable(dataFrame)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" # When\n",
|
" # When\n",
|
||||||
" pivotTableExpected = pd.DataFrame(\n",
|
" batchCodeTableExpected = pd.DataFrame(\n",
|
||||||
" {\n",
|
" {\n",
|
||||||
" 'ADRs': [2, 1],\n",
|
" 'ADRs': [2, 1],\n",
|
||||||
" 'DEATHS': [0, 1],\n",
|
" 'DEATHS': [0, 1],\n",
|
||||||
@@ -134,11 +117,11 @@
|
|||||||
" 'LIFE THREATENING ILLNESSES': [0.0, 0.0]\n",
|
" 'LIFE THREATENING ILLNESSES': [0.0, 0.0]\n",
|
||||||
" },\n",
|
" },\n",
|
||||||
" index = pd.MultiIndex.from_arrays([['025L20A', '037K20A']], names = ('VAX_LOT',)))\n",
|
" index = pd.MultiIndex.from_arrays([['025L20A', '037K20A']], names = ('VAX_LOT',)))\n",
|
||||||
" display(\"actual:\", pivotTable)\n",
|
" display(\"batchCodeTable:\", batchCodeTable)\n",
|
||||||
" display(\"expected:\", pivotTableExpected)\n",
|
" display(\"batchCodeTableExpected:\", batchCodeTableExpected)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" # Then\n",
|
" # Then\n",
|
||||||
" assert_frame_equal(pivotTable, pivotTableExpected, check_dtype = False)\n"
|
" assert_frame_equal(batchCodeTable, batchCodeTableExpected, check_dtype = False)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user