Files
HowBadIsMyBatch/src/CountryCountsByBatchcodeTablesMerger.py
frankknoll c2f4182fea merging
2023-06-09 16:46:49 +02:00

22 lines
855 B
Python

import pandas as pd
import glob
from CountryCountsByClickedBatchcodeProvider import CountryCountsByClickedBatchcodeProvider
class CountryCountsByBatchcodeTablesMerger:
@staticmethod
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/GoogleAnalytics/*')
return [CountryCountsByClickedBatchcodeProvider.getCountryCountsByClickedBatchcode(file) for file in files]