If you've invested time and effort in mastering Panda's dataframe styling (perhaps in the context of Jupyter), then you may want to preserve as much of that as possible when you present a dataframe in Flask.
If so, here are the relevant bits of code:
In your controller:
someDataTable = [styledDataFrame.to_html(classes='data', header="true")]
So let's say styledDataFrame was something like this:
styledDataFrame = someDF.style.set_table_styles([dict(selector='th', props=[('text-align', 'center')])])\
.hide(axis='index')\
.format(precision=1, thousands=",")
Okay, okay, maybe not the most amazing layout - but let's assume we like it, and want Flask to display basically what we see in Jupyter.
So then (still in the controller):
return render_template(
'dataViewer.html',
someNiceMetaData=someNiceMetaData,
sampleDataTable=sampleDataTable
)
And then in your template (which in this scenario would be called dataViewer.html):
{% block sampledata %}
<h3>Sample Data</h3>
{% for table in sampleDataTable %}
{{ table | safe }}
{% endfor %}
{% endblock %}
In this way you can continue to enrich your dataframe styler in Jupyter, and simply pass your best ideas through to Flask.
This approach is particularly compelling if, like me, you know way less about CSS than you do about Pandas, and you actually like the Pandas styler! (just me? Come on, the Pandas styler is really cool!)