File size: 646 Bytes
439ab17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pandas as pd

def format_df_to_string(df: pd.DataFrame, title: str) -> str:
    """Formats a pandas DataFrame into a markdown-like string for the prompt."""
    if df is None or df.empty:
        return ""
    
    header = f"### {title}\n"
    rows = []
    for _, row in df.iterrows():
        if 'Done' in df.columns and 'Task' in df.columns:
            status = "[x]" if row['Done'] else "[ ]"
            rows.append(f"- {status} {row['Task']}")
        elif 'Term' in df.columns and 'Description' in df.columns:
            rows.append(f"- **{row['Term']}**: {row['Description']}")
    
    return header + "\n".join(rows) + "\n\n"