Pandas Dataframe to_html or iterate over the data in the template?

Asked

Viewed 153 times

1

Actually I wanted to iterate on the data in the template?

But how do I play my pivot’s dice in context and treat them in the template?

df = pd.DataFrame(data)
pv = df.pivot(index='cands', columns='titles', values='grades')
context['quizzes'] = pv.to_html(classes='table', border=0, na_rep = '')

In the template I’m doing {{ quizzes }}, but I wanted to do

{% for quiz in quizzes %}
    <tr>
        <td>{{ quiz.first_name }}</td>
        <td>{{ quiz.title }}</td>
    </tr>
{% endfor %}

So on.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.