Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aloknayak29/b51c7d893268ef64a56e2bb85c8e68cd to your computer and use it in GitHub Desktop.
Save aloknayak29/b51c7d893268ef64a56e2bb85c8e68cd to your computer and use it in GitHub Desktop.
This is a python script created by LLM to create an html template with image and a pandas dataframe based table. Without any dependencies like jinja
import pandas as pd
df = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [25, 30, 35],
'City': ['Delhi', 'Mumbai', 'Bangalore']
})
html_template = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Image, Sentence, and DataFrame</title>
<style>
body {{
font-family: Arial, sans-serif;
margin: 40px;
text-align: center;
}}
img {{
max-width: 100%;
height: auto;
}}
.sentence {{
font-size: 1.2em;
margin: 20px 0;
}}
.dataframe-container {{
margin-top: 30px;
overflow-x: auto;
}}
table {{
margin: 0 auto;
border-collapse: collapse;
}}
table, th, td {{
border: 1px solid #ccc;
padding: 8px 12px;
}}
th {{
background-color: #f4f4f4;
}}
</style>
</head>
<body>
<img src="https://via.placeholder.com/600x200" alt="Top Image">
<div class="sentence">This is a summary of the dataset shown below.</div>
<div class="dataframe-container">
{df_table}
</div>
</body>
</html>
"""
with open("output.html", "w") as f:
f.write(html_template.format(df_table=df.to_html(index=False)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment