adding columns OVERALL_DOSES_SHIPPED and "Adverse Reaction Reports"

This commit is contained in:
frankknoll
2023-03-10 20:48:50 +01:00
parent 095f7f0b4c
commit bc03ef5277
4 changed files with 45 additions and 2 deletions

View File

@@ -36,6 +36,8 @@
<th>ZIPCODE_SHP</th> <th>ZIPCODE_SHP</th>
<th>LOT_NUMBER</th> <th>LOT_NUMBER</th>
<th>DOSES_SHIPPED</th> <th>DOSES_SHIPPED</th>
<th>OVERALL_DOSES_SHIPPED</th>
<th>Adverse Reaction Reports</th>
</tr> </tr>
</thead> </thead>
</table> </table>

File diff suppressed because one or more lines are too long

View File

@@ -182,7 +182,8 @@
"source": [ "source": [
"vaccineDistributionByZipcode = pd.read_excel(\n", "vaccineDistributionByZipcode = pd.read_excel(\n",
" io = 'tmp/Amended-22-01962-Pfizer-2022-0426-pulled-2022-0823.xlsx',\n", " io = 'tmp/Amended-22-01962-Pfizer-2022-0426-pulled-2022-0823.xlsx',\n",
" usecols = ['PROVIDER_NAME', 'ZIPCODE_SHP', 'LOT_NUMBER', 'DOSES_SHIPPED'])\n", " usecols = ['PROVIDER_NAME', 'ZIPCODE_SHP', 'LOT_NUMBER', 'DOSES_SHIPPED'],\n",
" dtype = {'DOSES_SHIPPED': 'int'})\n",
"vaccineDistributionByZipcode" "vaccineDistributionByZipcode"
] ]
}, },
@@ -199,6 +200,30 @@
"vaccineDistributionByZipcode" "vaccineDistributionByZipcode"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "8cd250f7",
"metadata": {},
"outputs": [],
"source": [
"OVERALL_DOSES_SHIPPED_by_LOT_NUMBER = vaccineDistributionByZipcode.groupby('LOT_NUMBER').agg(OVERALL_DOSES_SHIPPED = pd.NamedAgg(column = 'DOSES_SHIPPED', aggfunc = sum))\n",
"OVERALL_DOSES_SHIPPED_by_LOT_NUMBER"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a5667be",
"metadata": {},
"outputs": [],
"source": [
"from OVERALL_DOSES_SHIPPEDColumnAdder import OVERALL_DOSES_SHIPPEDColumnAdder\n",
"\n",
"vaccineDistributionByZipcode = OVERALL_DOSES_SHIPPEDColumnAdder(OVERALL_DOSES_SHIPPED_by_LOT_NUMBER).addColumn(vaccineDistributionByZipcode)\n",
"vaccineDistributionByZipcode"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,

View File

@@ -0,0 +1,16 @@
import pandas as pd
# FK-TODO: DRY with ADRColumnAdder
class OVERALL_DOSES_SHIPPEDColumnAdder:
def __init__(self, OVERALL_DOSES_SHIPPED_by_LOT_NUMBER):
self.OVERALL_DOSES_SHIPPED_by_LOT_NUMBER = OVERALL_DOSES_SHIPPED_by_LOT_NUMBER
def addColumn(self, vaccineDistributionByZipcode):
return pd.merge(
vaccineDistributionByZipcode,
self.OVERALL_DOSES_SHIPPED_by_LOT_NUMBER,
how = 'left',
left_on = 'LOT_NUMBER',
right_index = True,
validate = 'many_to_one')