0

I get data from the pandas(DataFrame), which is in list of lists, like [['jay', 'M', 'CS'],[],[]] and so on . How can i put this data in table. I directly push the list-data in html file. first loop works fine, but it didn't pass in second loop, How can I do that? I am new to html.

{% for post in post_data %}
   <tr>
   {% for value in post %}
       <td>
       {{value}}
       </td>
   {% endfor %}
   </tr>
{% endfor %}

i pass 'tables': [df.to_html(classes='data', header="true")], data display in raw html.

<div class="card card-stats">
    <div class="card-body ">
        <div class="card-header ">
            <!--div class="progress-container progress-info"-->
            <!--<h6 class="card -title" style="color:#FFFFFF; background-color:#008B8B;" align="center">DataFiles</h6>-->
            <table id="TripGrid" class="datafiletable" cellspacing="0" width="100%">
                <thead style="background-color: #6699FF">
                {% for header in post_header %}
                    <th>{{header}}</th>
                {% endfor %}
                </thead>
                <tbody>
                {% for table in tables %}
                    {{table}}
                {% endfor %}
                </tbody>
            </table><br>
        </div>
    </div>
</div>
Pratap
  • 33
  • 7
  • in you question you mentioned list `[['jay', 'M', 'CS'],[],[]]` , second and third lists are empty. so in `post` for second and third list it will not loop through. – Nihal Jan 25 '19 at 07:22
  • No it is not empty i write here only for format. – Pratap Jan 25 '19 at 07:25
  • 1
    what you have done is the correct way to do it. it should work. you should check your list. – Nihal Jan 25 '19 at 07:31
  • Or you can check my previous [answer](https://stackoverflow.com/a/52644615/7053679) , which convert dataframe to html table – Nihal Jan 25 '19 at 07:33
  • you assign data in dict format in list, i can't assign manually. – Pratap Jan 25 '19 at 07:38
  • in your question you mentioned that, `I get data from the pandas(DataFrame)`. i assumed that you have data in your dataframe. you just need to pass in `to_html`. in my answer i made a dict to create dataframe for ease. – Nihal Jan 25 '19 at 07:41
  • @Nihal i check your answer and pass in to_html, now problem is how can i display correctly. – Pratap Jan 25 '19 at 07:54

0 Answers0