熊猫数据框到AnguarJS
问题描述:
我有一个RESTful架构,其中AngularJS使用DRF API。现在,随着大熊猫,我转换我的数据框到HTML表,但我想不出如何将它发送到AngularJS和呈现它。数据帧表看起来像这样 -熊猫数据框到AnguarJS
<table border="1" class="dataframe table">
<thead>
<tr style="text-align: right;">
<th>2014-09-01</th>
<th>2014-12-01</th>
</tr>
</thead>
<tbody>
<tr>
<td>1.460000</td>
<td>7.100000</td>
<td>17.5300</td>
</tr>
</tbody>
等等,它是一张大桌子。现在,无论我是否可以将其存储为在django中转义,但我如何让AngularJS使用它?另外,如何将它保存在django textfield()
中?
答
它没有改变任何东西。在.to_html
之后,将数据帧保存到textfiled()
,使用drf对其进行序列化,并在AngularJS中使用ng-sanitize并对表格进行渲染。
答
pandas.DataFrame.to_json()
然后渲染AngluarJS会不会更容易?感觉像html步骤增加了复杂性。
它有很多''s,即使使用ng-repeat也有很多硬编码,也是一个大表,并且有很多标题使它在AngularJS中变得复杂 – ThatBird