Files
HowBadIsMyBatch/HowBadIsMyBatch.ipynb
frankknoll ce588d502a refactoring
2022-01-25 10:50:14 +01:00

123 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "9de5907f-18f5-4cb1-903e-26028ff1fa03",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"pd.set_option('display.max_rows', 100)\n",
"pd.set_option('display.max_columns', None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "233bc590",
"metadata": {},
"outputs": [],
"source": [
"def createDataFrame(manufacturer):\n",
" def read_csv(file):\n",
" return pd.read_csv(file, index_col='VAERS_ID', encoding='latin1', low_memory=False)\n",
" \n",
" def createDataFrameForYear(year):\n",
" folder = \"VAERS/\" + year + \"VAERSData/\"\n",
" return pd.merge(\n",
" read_csv(folder + year + \"VAERSDATA.csv\"),\n",
" read_csv(folder + year + \"VAERSVAX.csv\"),\n",
" left_index=True,\n",
" right_index=True)\n",
" \n",
" df = pd.concat([createDataFrameForYear(\"2021\"), createDataFrameForYear(\"2022\")])\n",
" return df[(df[\"VAX_TYPE\"] == \"COVID19\") & (df[\"VAX_MANU\"] == manufacturer)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "99945ca8",
"metadata": {},
"outputs": [],
"source": [
"def createPivotTable(df):\n",
" def filter(df, col):\n",
" return df[df[col]=='Y'][['VAX_LOT']]\n",
"\n",
" return pd.concat(\n",
" {\n",
" 'ADRs': df[['VAX_LOT']].value_counts(),\n",
" 'DEATHS': filter(df, 'DIED').value_counts(),\n",
" 'DISABILITIES': filter(df, 'DISABLE').value_counts(),\n",
" 'LIFE THREATENING ILLNESSES': filter(df, 'L_THREAT').value_counts()\n",
" },\n",
" axis=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "86e0e4f2",
"metadata": {},
"outputs": [],
"source": [
"df_moderna = createDataFrame(\"MODERNA\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab170c16",
"metadata": {},
"outputs": [],
"source": [
"df_moderna"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d9191d12",
"metadata": {},
"outputs": [],
"source": [
"pivotTable = createPivotTable(df_moderna)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb7b2963",
"metadata": {},
"outputs": [],
"source": [
"pivotTable"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}