Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

Reformat a python table in a html file

import numpy as np
from numpy.random import randn
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(randn(5,4),columns='W X Y Z'.split())
df1 = pd.DataFrame(randn(5,4),columns='A B C D'.split())
df2 = pd.DataFrame(randn(5,4),columns='E F G K'.split())

html = """
    {table1}
    <table>
      <tr>
        <td>{table2}</td>
        <td>{table3}</td>
      </tr>
    </table>
    """.format(
        table1=df.head().to_html(),
        table2=df1.head().to_html(),
        table3=df2.head().to_html()
    )
with open("a.html", 'w') as _file:
    _file.write(html)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Reformat #python #table #html #file
ADD COMMENT
Topic
Name
5+6 =