"""
"Stat: Data Cleanup for HTC (Point Calculation)" Module
=======================================================
A post-processing module cleaning update csv collect from HTC
The generated table and unit dictionary will be used in notebook
"""
import pandas as pd
from typing import Tuple
from panpython._libs.parser import MergedCsvCleaner
[docs]class HtcPointInterpreter:
"""A cleanup instance for post-process of merged HTC data
Parameters
----------
csv_path: str
a full path to csv file
Examples
--------
>>> from panpython.sdk.stat.data_cleanup_for_htc_point import HtcPointInterpreter
>>> data_file = './output/merged_default.table.csv'
>>> default_interpreter = HtcPointInterpreter(data_file)
>>>
>>> default_table = pd.DataFrame()
>>> default_units = {}
>>> try:
>>> default_table, default_units = default_interpreter.get_table_and_units()
>>> print(data_file, 'is loaded')
>>> except FileNotFoundError as e:
>>> print(e)
"""
def __init__(self, csv_path):
"""
Initialize htc point interpreter class
Parameters
----------
csv_path: str
a full path to csv file
Returns
-------
"""
self._m_cleaner = MergedCsvCleaner(csv_path=csv_path)
return
[docs] def get_table_and_units(self) -> Tuple[pd.DataFrame, dict]:
"""
Get units dict and a DataFrame table without units
Parameters
----------
Returns
-------
pd.DataFrame
The table after cleanup
dict
The units dictionary of the table
"""
return self._m_cleaner.get_table_and_units()