EVAL/core/handlers/dataframe.py
ChungHwan Han 3ec0cc786c
Feature/better usability (#6)
* refactor: api, core

* feat: static uploader

* doc: update readme

* fix: mkdir static file

* doc: typo
2023-03-23 16:33:45 +09:00

22 lines
595 B
Python

import pandas as pd
from core.prompts.file import DATAFRAME_PROMPT
from .base import BaseHandler
class CsvToDataframe(BaseHandler):
def handle(self, filename: str):
df = pd.read_csv(filename)
description = (
f"Dataframe with {len(df)} rows and {len(df.columns)} columns."
"Columns are: "
f"{', '.join(df.columns)}"
)
print(
f"\nProcessed CsvToDataframe, Input CSV: {filename}, Output Description: {description}"
)
return DATAFRAME_PROMPT.format(filename=filename, description=description)