I am using Flask but this probably applies to a lot of similar frameworks.
I construct a pandas Dataframe, e.g.
@app.route('/analysis/<filename>')
def analysis(filename):
x = pd.DataFrame(np.random.randn(20, 5))
return render_template("analysis.html", name=filename, data=x)
The template analysis.html looks like
{% extends "base.html" %}
{% block content %}
<h1>{{name}}</h1>
{{data}}
{% endblock %}
This works but the output looks horrible. It doesn't use linebreaks etc.
I have played with data.to_html()
and data.to_string()
What's the easiest way to display a frame?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…