Mohd Bilal
Mohd Bilal

Reputation: 101

Pandas multiple Dataframes to HTML page with Headers

I am trying to add multiple Dataframes to a single HTML page with different Headers.

Currently, I am using to_html function to add multiple Dataframes in the HTML page.

Can anyone please help me to add multiple DFs in one page with line breaks and Headers like tags.

Thank You

Upvotes: 0

Views: 1331

Answers (1)

Mohd Bilal
Mohd Bilal

Reputation: 101

Maybe it is not a very big problem, But it may help someone

Here is my code:

with open("Result.html", 'w') as _file:
    _file.write('<center>' 
                +'<h1> Main Heading </h1><br><hr>'
                +'<h2> Heading1 </h2>' + df1.to_html(index=False,border=2,justify="center") + '<be><hr>'
                +'<h2> Heading2 </h2>' + df2.to_html(index=False,border=2,justify="center") + '<br><hr>'
                +'<h2> Heading3 </h2>' + df3.to_html(index=False,border=2,justify="center") + '<br><hr>'
                +'</center>')

Upvotes: 1

Related Questions