Download plugins/outputs/table_formatter.py from JatinAutonomousLabs/Excel_AI_Assistant: direct link, hf CLI and curl.
- Browser
- Download file 597 Bytes
-
https://huggingface.co/spaces/JatinAutonomousLabs/Excel_AI_Assistant/resolve/main/plugins/outputs/table_formatter.py
- Command line
-
hf download hf://spaces/JatinAutonomousLabs/Excel_AI_Assistant/plugins/outputs/table_formatter.py
-
curl -L -o table_formatter.py https://huggingface.co/spaces/JatinAutonomousLabs/Excel_AI_Assistant/resolve/main/plugins/outputs/table_formatter.py
597 Bytes
| #!/usr/bin/env python3 | |
| """Table Formatting Plugin""" | |
| import pandas as pd | |
| from tabulate import tabulate | |
| class TableFormatter: | |
| """Format DataFrames as tables.""" | |
| def format_to_markdown(self, df: pd.DataFrame, headers: str = "keys") -> str: | |
| if df.empty: | |
| return "No data to display." | |
| return tabulate(df, headers=headers, tablefmt="github", showindex=False) | |
| def format_to_html(self, df: pd.DataFrame) -> str: | |
| if df.empty: | |
| return "No data to display." | |
| return df.to_html(index=False, classes="table-auto w-full text-left border") | |