adding CountryCountsByBatchcodeTablesMerger

This commit is contained in:
frankknoll
2023-06-02 14:36:48 +02:00
parent b0142cef77
commit c733e26c45
5 changed files with 49 additions and 20 deletions

View File

@@ -1,10 +1,21 @@
import pandas as pd
import glob
from CountryCountsByClickedBatchcodeProvider import CountryCountsByClickedBatchcodeProvider
class CountryCountsByBatchcodeTablesMerger:
@staticmethod
def merge(countryCountsByBatchcodeTables):
def mergeCountryCountsByBatchcodeTables(countryCountsByBatchcodeTables):
return (pd
.concat(countryCountsByBatchcodeTables)
.groupby(countryCountsByBatchcodeTables[0].index.names)
.sum())
@staticmethod
def getCountryCountsByClickedBatchcodeTable():
return CountryCountsByBatchcodeTablesMerger.mergeCountryCountsByBatchcodeTables(CountryCountsByBatchcodeTablesMerger._getTables())
@staticmethod
def _getTables():
files = glob.glob(r'data/*')
return [CountryCountsByClickedBatchcodeProvider.getCountryCountsByClickedBatchcode(file) for file in files]