# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/utils/convert.ipynb.

# %% auto 0
__all__ = ['convert_epoch_millisecond_to_datetime', 'convert_datetime_to_epoch_millisecond', 'convert_snake_to_pascal',
           'ConcatDataframe_InvalidElement', 'concat_list_dataframe']

# %% ../../nbs/utils/convert.ipynb 2
import datetime as dt
import pandas as pd

# %% ../../nbs/utils/convert.ipynb 5
def convert_epoch_millisecond_to_datetime(epoch: int):
    '''convert Epoch time with miliseconds to Date time'''
    return dt.datetime.fromtimestamp(epoch / 1000.0)

# %% ../../nbs/utils/convert.ipynb 6
def convert_datetime_to_epoch_millisecond(datetime: dt.datetime):
    '''convert DateTime to Epoch time with Miliseconds'''
    return int(datetime.timestamp() * 1000)

# %% ../../nbs/utils/convert.ipynb 10
def convert_snake_to_pascal(str):
    """converts 'snake_case_str' to 'snakeCaseStr'"""
    
    clean_str = str.replace("_", " ").title().replace(" ", "")
    return clean_str[0].lower()+clean_str[1:]

# %% ../../nbs/utils/convert.ipynb 14
class ConcatDataframe_InvalidElement(Exception):
    def __init__(self, elem):
        message = f"{type(elem)} passed into dataframe"
        super().__init__(message)

def concat_list_dataframe(df_ls : list[pd.DataFrame]) -> pd.DataFrame:
    """take a list of dataframes and collapse into one dataframe"""

    df = None
    for elem in df_ls:
        if not isinstance(elem, pd.DataFrame):
            raise ConcatDataframe_InvalidElement(elem)
        
        if len(elem.index) == 0:
            pass
        
        if df is None:
            df = elem

        else:
            df = pd.concat([df, elem], join = 'inner').reset_index(drop = True)
    return df
