This commit is contained in:
frankknoll
2023-01-26 23:33:45 +01:00
parent 56a903ebbe
commit 6e91398383

View File

@@ -163,9 +163,34 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from HistogramTable2JsonTableConverter import HistogramTable2JsonTableConverter\n", "from HistogramTable2DictTableConverter import HistogramTable2DictTableConverter\n",
"jsonTable = HistogramTable2JsonTableConverter.convertHistogramTable2JsonTable(symptomHistogramByBatchcodeTable)\n", "dictByBatchcodeTable = HistogramTable2DictTableConverter.convertHistogramTable2DictTable(symptomHistogramByBatchcodeTable)\n",
"jsonTable" "dictByBatchcodeTable"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ba9f665a",
"metadata": {},
"outputs": [],
"source": [
"from TableByBatchcodeFilter import TableByBatchcodeFilter\n",
"filteredTable = TableByBatchcodeFilter.filterTableByBatchcode('FE6208', dictByBatchcodeTable)\n",
"filteredTable"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c7027164",
"metadata": {},
"outputs": [],
"source": [
"from DictByBatchcodeTable2JsonConverter import DictByBatchcodeTable2JsonConverter\n",
"import json\n",
"jsonActual = DictByBatchcodeTable2JsonConverter.convertDictByBatchcodeTable2Json(filteredTable, 'FE6208')\n",
"print(json.dumps(json.loads(jsonActual), indent=2))"
] ]
}, },
{ {
@@ -178,6 +203,50 @@
"jsonTable.to_excel('tmp/jsonTable.xlsx')" "jsonTable.to_excel('tmp/jsonTable.xlsx')"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "1d5a7864",
"metadata": {},
"outputs": [],
"source": [
"filteredTable.to_excel('tmp/filteredTable.xlsx')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0daf7fdc",
"metadata": {},
"outputs": [],
"source": [
"from TestHelper import TestHelper\n",
"batchcode = '1808982'\n",
"symptomHistogramByBatchcodeTable = TestHelper.createDataFrame(\n",
" columns = ['SYMPTOM_COUNT_BY_VAX_LOT'],\n",
" data = [ ['{\"Blood pressure orthostatic abnormal\":5,\"Chest discomfort\":1}'],\n",
" ['{\"Chest discomfort\":2}']],\n",
" index = pd.MultiIndex.from_tuples(\n",
" names = ['VAX_LOT1', 'VAX_LOT2'],\n",
" tuples = [[batchcode, 'EW0175'],\n",
" ['015M20A', batchcode]]))\n",
"symptomHistogramByBatchcodeTable"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e63a507",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"result= symptomHistogramByBatchcodeTable.to_json()\n",
"parsed = json.loads(result)\n",
"parsed\n",
"#print(json.dumps(parsed, indent=4))"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -199,18 +268,6 @@
"res.to_json()" "res.to_json()"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "f2e59589",
"metadata": {},
"outputs": [],
"source": [
"df = symptomHistogramByBatchcodeTable[:].reset_index()\n",
"vax_lot = '094F21A'\n",
"df[(df['VAX_LOT1'] == vax_lot) | (df['VAX_LOT2'] == vax_lot) | (df['VAX_LOT3'] == vax_lot) | (df['VAX_LOT4'] == vax_lot) | (df['VAX_LOT5'] == vax_lot) | (df['VAX_LOT6'] == vax_lot) | (df['VAX_LOT7'] == vax_lot) | (df['VAX_LOT8'] == vax_lot) | (df['VAX_LOT9'] == vax_lot) | (df['VAX_LOT10'] == vax_lot)]"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -231,51 +288,6 @@
"symptomHistogramByBatchcodeTable.sort_values(by='SYMPTOM_COUNT_BY_VAX_LOT', ascending=False)" "symptomHistogramByBatchcodeTable.sort_values(by='SYMPTOM_COUNT_BY_VAX_LOT', ascending=False)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "206980b7",
"metadata": {},
"outputs": [],
"source": [
"df = symptomByBatchcodeTable[:].reset_index()\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "690197ca",
"metadata": {},
"outputs": [],
"source": [
"table = df.groupby(['VAX_LOT1', 'VAX_LOT2'])['SYMPTOM'].value_counts()\n",
"table.name = 'SYMPTOM_count'\n",
"# table = table.reset_index(level = table.index.names.difference(['VAX_LOT1', 'VAX_LOT2']))\n",
"table"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6e2c82e",
"metadata": {},
"outputs": [],
"source": [
"table2 = table.reset_index(level=2)\n",
"table2"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cb7bf7e4",
"metadata": {},
"outputs": [],
"source": [
"table2.index"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@@ -473,7 +485,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.8 (main, Nov 24 2022, 14:13:03) [GCC 11.2.0]" "version": "3.10.8"
}, },
"vscode": { "vscode": {
"interpreter": { "interpreter": {