from fasthtml import common as fh def df2fhtml(df: pd.DataFrame, with_headers: bool=True, **kwargs): cols = df.columns header = fh.Tr(*[fh.Th(fh.Label(col)) for col in cols]) rows = [fh.Tr(*[fh.Td(df[col][i]) for col in cols]) for i in range(len(df))] return fh.Table(header if with_headers else '', *rows, **kwargs)