This may sound a noob question, but I\'m stuck with it as Python is not one of my best languages.
I have a html page with a table inside it, and I would like to show
# Declare table
class SomeTable(Table):
status = Col('Customer')
city = Col('City')
product_price = Col('Country')
# Convert the pandas Dataframe into dictionary structure
output_dict = output.to_dict(orient='records')
# Populate the table
table = SomeTable(output_dict)
return (table.__html__())
or as pandas return static HTML file you can render it as page using Flask
@app.route('//')
def render_static(filename):
return render_template('%s.html' % filename)
It's the Idea of how we can do it in Flask. Hope you can understand this and let me know if it's not helping!
import pandas as pd
df = pd.DataFrame({'col1': ['abc', 'def', 'tre'],
'col2': ['foo', 'bar', 'stuff']})
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return df.to_html(header="true", table_id="table")
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
But I'd go with Flask HTML feature rather than DataFrame to HTML (due to styling)