Files
HowBadIsMyBatch/src/CountriesByBatchcodeProvider.py
frankknoll 80b7448aed refactoring
2023-03-30 15:36:39 +02:00

41 lines
2.2 KiB
Python

import pandas as pd
from CompletedBatchcodeColumnAdder import CompletedBatchcodeColumnAdder
from BatchcodeCompletion import BatchcodeCompletion
from CountriesColumnAdder import CountriesColumnAdder
from BatchCodeTableFactory import BatchCodeTableFactory
from InternationalVaersCovid19Provider import getInternationalVaersCovid19
def getCountriesByCompletedBatchcode(internationalVaersCovid19):
result = _readExploration('data/Country By Batchcode Search Term.csv', indexName = 'Batchcode Search Term')
result = _addCompletedBatchcodeColumn(result, internationalVaersCovid19)
columnName = 'Countries'
result = CountriesColumnAdder().addCountriesColumn(result, columnName = columnName)
return result[[columnName]].droplevel('Batchcode Search Term')
def _addCompletedBatchcodeColumn(country_By_Batchcode_Search_Term, internationalVaersCovid19):
return CompletedBatchcodeColumnAdder(_getCompleteBatchcode(internationalVaersCovid19)).addCompletedBatchcodeColumn(country_By_Batchcode_Search_Term)
def _getCompleteBatchcode(internationalVaersCovid19):
batchCodeTable = BatchCodeTableFactory(internationalVaersCovid19).createGlobalBatchCodeTable()
return BatchcodeCompletion(ADR_by_Batchcode = batchCodeTable).completeBatchcode
def getCountriesByClickedBatchcode():
result = _readExploration('data/Country By Clicked Batchcode.csv', indexName = 'Clicked Batchcode')
columnName = 'Countries'
result = CountriesColumnAdder().addCountriesColumn(result, columnName = columnName)
return result[[columnName]]
def _readExploration(csvFile, indexName):
exploration = pd.read_csv(csvFile, header=[0], index_col=0, skiprows=6, on_bad_lines='warn')
exploration.drop(index=indexName, inplace=True)
exploration.index.rename(indexName, inplace=True)
exploration.drop(columns='Totals', inplace=True)
for column in exploration.columns:
exploration[column] = exploration[column].astype('int64')
return exploration
def getCountriesByBatchcodeBeforeDeletion():
internationalVaersCovid19 = getInternationalVaersCovid19(dataDir = 'VAERS/VAERSBeforeDeletion', years = [2020, 2021, 2022])
batchCodeTable = BatchCodeTableFactory(internationalVaersCovid19).createGlobalBatchCodeTable()
return batchCodeTable[['Countries']]