mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
25 lines
684 B
Python
25 lines
684 B
Python
import pandas as pd
|
|
import os
|
|
|
|
|
|
class DataLoader:
|
|
|
|
@staticmethod
|
|
def load(filepath: str, index_col: str = None) -> pd.DataFrame:
|
|
"""
|
|
Load different datasets
|
|
"""
|
|
|
|
if not os.path.exists(filepath):
|
|
raise FileNotFoundError(f"File not found: {filepath}")
|
|
|
|
if filepath.endswith('.parquet'):
|
|
df = pd.read_parquet(filepath)
|
|
if index_col is not None:
|
|
df = df.set_index(index_col)
|
|
elif filepath.endswith('.csv'):
|
|
df = pd.read_csv(filepath, index_col=index_col)
|
|
else:
|
|
raise ValueError(f"File format not supported for file: {filepath}")
|
|
|
|
return df
|