20250225 ‐ html - cywongg/2025 GitHub Wiki

import pandas as pd

# Example DataFrame
data = {'Name': ['Alice', 'Bob', 'Charlie'],
        'Age': [25, 30, 35],
        'City': ['New York', 'Los Angeles', 'Chicago']}
df = pd.DataFrame(data)

# Generate HTML and clean it
html_table = df.to_html(index=False, border=0)  # Generate HTML
html_table = html_table.replace('<thead>', '').replace('</thead>', '')  # Remove <thead>
html_table = html_table.replace('<tbody>', '').replace('</tbody>', '')  # Remove <tbody>
html_table = html_table.replace(' border="1"', '')  # Remove border attribute
html_table = html_table.replace(' style="text-align: right;"', '')  # Remove style attribute

print(html_table)
⚠️ **GitHub.com Fallback** ⚠️